Class: Kettle::Family::CLI
- Inherits:
-
Object
- Object
- Kettle::Family::CLI
- Defined in:
- lib/kettle/family/cli.rb
Defined Under Namespace
Classes: StartAt
Constant Summary collapse
- COMMANDS =
%w[discover plan report metadata check test lint docs template gha-sha-pins bup bupb bex install bump-version add-changelog release push pull up branch-lanes release-state].freeze
- WORKFLOW_COMMANDS =
%w[check test lint docs template gha-sha-pins bup bupb bex release push pull up].freeze
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(argv, out:, err:) ⇒ CLI
constructor
A new instance of CLI.
Constructor Details
#initialize(argv, out:, err:) ⇒ CLI
Returns a new instance of CLI.
16 17 18 19 20 |
# File 'lib/kettle/family/cli.rb', line 16 def initialize(argv, out:, err:) @argv = argv.dup @out = out @err = err end |
Class Method Details
.call(argv, out: $stdout, err: $stderr) ⇒ Object
12 13 14 |
# File 'lib/kettle/family/cli.rb', line 12 def self.call(argv, out: $stdout, err: $stderr) new(argv, out: out, err: err).call end |
Instance Method Details
#call ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/kettle/family/cli.rb', line 22 def call command = argv.shift || "help" return help if command == "help" || command == "--help" || command == "-h" raise Error, "unknown command #{command.inspect}" unless COMMANDS.include?(command) target_version = argv.shift if command == "bump-version" raise Error, "bump-version requires VERSION, major, minor, patch, or pre" if command == "bump-version" && !target_version bup_args = parse_bup_args(command) bex_args = parse_bex_args_with_separator(command) = (allow_remainder: command == "bex" && bex_args.empty?) bex_args = argv.shift(argv.length) if command == "bex" && bex_args.empty? raise Error, "bex requires COMMAND [ARGS]" if command == "bex" && bex_args.empty? [:target_version] = target_version [:bup_args] = bup_args [:bex_args] = bex_args return help if .delete(:help) report = build_report(command, ) write_report(report, ) out.puts([:json] ? report.to_json : report.to_text) report.success? ? 0 : 1 rescue Error, OptionParser::ParseError => error err.puts("kettle-family: #{error.}") 1 end |