lib/site_hook/cli.rb in site_hook-0.8.0 vs lib/site_hook/cli.rb in site_hook-0.8.1
- old
+ new
@@ -1,32 +1,48 @@
-require 'thor'
-require 'site_hook/config_class'
-require 'site_hook/server_class'
-#require 'site_hook/debug_class'
+require 'gli'
+require 'highline'
+require 'paint'
+require 'pathname'
+require 'site_hook/exceptions'
+require 'site_hook/deprecate'
module SiteHook
- class CLI < Thor
- map %w[--version -v] => :__print_version
- desc '--version, -v', 'Print the version'
-
- # Prints version string
- # @return [NilClass] nil
- def __print_version
- puts "Version: v#{SiteHook::VERSION}"
+ class App
+ extend GLI::App
+ version SiteHook::VERSION
+ # don't use config_file just use ~/.shrc/config's cli:...
+ # projects are in .shrc/config
+ commands_from 'site_hook/commands'
+ desc 'Print info on the gem.'
+ command 'gem-info' do |c|
+ c.action do |global_options, options, arguments|
+ @hl.say "Gem Name: #{SiteHook::Gem::Info.name}"
+ @hl.say "Gem Constant: #{SiteHook::Gem::Info.constant_name}"
+ @hl.say "Gem Author: #{SiteHook::Gem::Info.author}"
+ @hl.say "Gem Version: v#{SiteHook::VERSION}"
+ end
end
-
- map %w(--gem-info --info --about) => :__gem_info
- desc '--gem-info, --info, --about', 'Print info on the gem.'
- def __gem_info
- say "Gem Name: #{SiteHook::Gem::Info.name}"
- say "Gem Constant: #{SiteHook::Gem::Info.constant_name}"
- say "Gem Author: #{SiteHook::Gem::Info.author}"
- say "Gem Version: v#{SiteHook::VERSION}"
+ around do |global_options, command, options, args, code|
+ @config_hash = YAML.load_file(SiteHook::Paths.config) || YAML.load_file(SiteHook::Paths.old_config)
+ @hl = HighLine.new(STDIN, STDOUT, 80, 1, 2, 0)
+ code.call
end
- desc 'config SUBCOMMAND [OPTIONS]', 'Configure site_hook options'
- subcommand('config', SiteHook::ConfigClass)
- desc 'server SUBCOMMAND [OPTIONS]', 'Start the server'
- subcommand('server', SiteHook::ServerClass)
- #desc 'debug SUBCOMMAND [OPTIONS]', 'Debug the Gem'
- #subcommand('debug', SiteHook::DebugClass)
+ pre do |global_options, command, options, args|
+ if SiteHook::Paths.old_config.exist?
+ continue = SiteHook::Deprecation.deprecate(
+ "#{SiteHook::Paths.old_config.to_s} is deprecated in favor of #{SiteHook::Paths.config}",
+ <<~INSTRUCT,
+ Please run `#{exe_name} config upgrade-shrc` to rectify this.
+ Once version 1.0.0 is released, #{SiteHook::Paths.config} will
+ be the only config file option, and #{SiteHook::Paths.old_config} will not be allowed.
+ any existance of ~/.jph after the 1.0.0 release will result in an Exception being raised.
+ Once the exception is raised, site_hook will exit and return a 99 status code.
+ INSTRUCT
+ true
+ )
+ continue
+ else
+ # don't do anything
+ end
+ end
end
end