class Snaptoken::CLI
Constants
- CONFIG_FILE
Public Class Methods
new()
click to toggle source
# File lib/snaptoken/cli.rb, line 4 def initialize initial_dir = FileUtils.pwd last_dir = nil while FileUtils.pwd != last_dir if File.exist?(CONFIG_FILE) @config = YAML.load(File.read(CONFIG_FILE)) if @config == false puts "Error: Invalid config file." exit! end @config = {} unless @config.is_a?(Hash) @config[:path] = FileUtils.pwd break end last_dir = FileUtils.pwd FileUtils.cd('..') end FileUtils.cd(initial_dir) end
Public Instance Methods
run(args)
click to toggle source
# File lib/snaptoken/cli.rb, line 27 def run(args) args = ["help"] if args.empty? cmd_name = args.shift.downcase if cmd_name =~ /\A\d+\z/ args.unshift(cmd_name) cmd_name = "ref" end if cmd = Snaptoken::Commands::LIST.find { |cmd| cmd.name == cmd_name } cmd.new(args, @config).run else puts "There is no '#{cmd_name}' command. Run `leg help` for help." end end