class Agile::CLI
Public Class Methods
help(shell, subcommand = false)
click to toggle source
# File lib/agile/commands/help.rb, line 6 def help(shell, subcommand = false) list = printable_commands(true, subcommand) Thor::Util.thor_classes_in(self).each do |klass| list += klass.printable_commands(false) end list.sort! { |a, b| a[0] <=> b[0] } list.reject! { |l| l[0].split[1] == 'help' } if defined?(@package_name) && @package_name shell.say "#{@package_name} commands:" else shell.say Rainbow('Commands:').whitesmoke end shell.print_table(list, indent: 2, truncate: true) shell.say class_options_help(shell) shell.say Rainbow('All commands can be run with -h (or --help) for more information.').whitesmoke shell.say Rainbow('Homepage https://github.com/rubizza-camp/AgileCli').whitesmoke end
Public Instance Methods
DoD()
click to toggle source
# File lib/agile/commands/dod.rb, line 6 def DoD dod = [] dod << File.read("#{GEM_PATH}/agile/assets/definition_of_done.txt") say Terminal::Table.new title: "Definition of Done", rows: [dod], style: TERMINAL_STYLE end
DoR()
click to toggle source
# File lib/agile/commands/dor.rb, line 6 def DoR dor = [] dor << File.read("#{GEM_PATH}/agile/assets/definition_of_ready.txt") say Terminal::Table.new title: "Definition of Ready", rows: [dor], style: TERMINAL_STYLE end
hello()
click to toggle source
# File lib/agile/commands/hello.rb, line 4 def hello say "Hello world!" end
init(remote)
click to toggle source
# File lib/agile/commands/init.rb, line 7 def init(remote) error_checking_init write_remote_to_config(remote) say "Successfully added new remote!" end
login()
click to toggle source
# File lib/agile/commands/login.rb, line 6 def login error_checking_login open_link @secret_node = call_cli @response = RestClient.get "#{CONFIG['current_remote']}/api/v1/users/#{@secret_node}" if JSON.parse(@response)["data"]["attributes"] parse_login else say "Something went wrong" end end
manifesto()
click to toggle source
# File lib/agile/commands/manifesto.rb, line 4 def manifesto manifest = [] manifest << File.read("#{GEM_PATH}/agile/assets/manifesto.txt") say Terminal::Table.new title: "Manifesto", rows: [manifest], style: TERMINAL_STYLE end
principles()
click to toggle source
# File lib/agile/commands/principles.rb, line 4 def principles principl = [] principl << File.read("#{GEM_PATH}/agile/assets/agile_principles.txt") say Terminal::Table.new title: "Agile principles", rows: [principl], style: TERMINAL_STYLE end
values()
click to toggle source
# File lib/agile/commands/values.rb, line 4 def values values = [] values << File.read("#{GEM_PATH}/agile/assets/agile_values.txt") say Terminal::Table.new title: "Values", rows: [values], style: TERMINAL_STYLE end
version()
click to toggle source
# File lib/agile/commands/version.rb, line 4 def version say "agile #{Agile::VERSION}" end
Private Instance Methods
call_cli()
click to toggle source
# File lib/agile/commands/login.rb, line 32 def call_cli cli = HighLine.new cli.ask("Enter your secret code: ", String) end
error_checking_init()
click to toggle source
# File lib/agile/commands/init.rb, line 15 def error_checking_init abort "You've already did init! Try to add more remotes" if CONFIG["current_remote"] end
error_checking_login()
click to toggle source
# File lib/agile/commands/login.rb, line 48 def error_checking_login abort "You haven't done init yet!" unless CONFIG["current_remote"] end
open_link()
click to toggle source
# File lib/agile/commands/login.rb, line 37 def open_link link = "#{GITHUB_URL}/oauth/authorize?client_id=#{CLIENT_ID}" if RbConfig::CONFIG["host_os"].match?(/mswin|mingw|cygwin/) system "start #{link}" elsif RbConfig::CONFIG["host_os"].match?(/darwin/) system "open #{link}" elsif RbConfig::CONFIG["host_os"].match?(/linux|bsd/) system "xdg-open #{link}" end end
parse_login()
click to toggle source
# File lib/agile/commands/login.rb, line 26 def parse_login login = JSON.parse(@response)["data"]["attributes"]["github_login"] write_to_config(login) say "Hello, #{login}!" end
write_remote_to_config(remote)
click to toggle source
# File lib/agile/commands/init.rb, line 19 def write_remote_to_config(remote) CONFIG["current_remote"] = remote CONFIG["remotes"] = [remote] File.write("#{GEM_PATH}.config.json", JSON.generate(CONFIG)) end
write_to_config(login)
click to toggle source
# File lib/agile/commands/login.rb, line 20 def write_to_config(login) CONFIG["current_user"] = login CONFIG["user_node"] = @secret_node File.write("#{GEM_PATH}.config.json", JSON.generate(CONFIG)) end