lib/pbmenv/cli.rb in pbmenv-0.1.12 vs lib/pbmenv/cli.rb in pbmenv-0.1.13

- old
+ new

@@ -1,27 +1,31 @@ module Pbmenv class CLI + class CLIError < StandardError; end + def self.run(argv) sub_command = argv[0] case sub_command when 'available_versions', 'av' Pbmenv.available_versions.each { |x| puts x } when 'versions', 'list' - Pbmenv.versions.each { |x| puts x } + Pbmenv.command_versions.each { |x| puts x } when 'install', 'i' sub_command_arg = argv[1] + use_option = false case argv[2] when "--use" use_option = true when nil - use_option = false else puts <<~EOH Unknown option: available options: --use EOH + raise CLIError end + Pbmenv.install(sub_command_arg, use_option: use_option) when 'use', 'u' sub_command_arg = argv[1] Pbmenv.use(sub_command_arg) when 'uninstall' @@ -35,12 +39,20 @@ Pbmenv.clean(version_size_to_keep) when '--version' puts Pbmenv::VERSION else puts <<~EOH - Unknown command: - available commands: available_versions, versions, install, use, uninstall, clean + Usage: pbmenv [command] + + Available commands: + available_versions Display the available versions of pbmenv + versions List the installed versions of pbmenv + install Install a specific version of pbmenv + use Set a specific version of pbmenv as the active version + uninstall Uninstall a specific version of pbmenv + clean Remove old installed versions of pbmenv EOH + raise CLIError end end end end