rfix 1.4.1 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/exe/rfix +78 -34
- data/lib/rfix.rb +17 -28
- data/lib/rfix/branch.rb +3 -25
- data/lib/rfix/branch/base.rb +27 -0
- data/lib/rfix/branch/head.rb +15 -0
- data/lib/rfix/branch/main.rb +33 -0
- data/lib/rfix/branch/name.rb +21 -0
- data/lib/rfix/branch/reference.rb +15 -0
- data/lib/rfix/branch/upstream.rb +17 -0
- data/lib/rfix/cli/command.rb +19 -0
- data/lib/rfix/cli/command/base.rb +61 -0
- data/lib/rfix/cli/command/branch.rb +13 -0
- data/lib/rfix/cli/command/config.rb +22 -0
- data/lib/rfix/cli/command/extension.rb +25 -0
- data/lib/rfix/cli/command/help.rb +11 -0
- data/lib/rfix/cli/command/info.rb +11 -0
- data/lib/rfix/cli/command/lint.rb +17 -0
- data/lib/rfix/cli/command/local.rb +11 -0
- data/lib/rfix/cli/command/origin.rb +11 -0
- data/lib/rfix/cli/command/setup.rb +11 -0
- data/lib/rfix/error.rb +5 -1
- data/lib/rfix/extension/offense.rb +79 -0
- data/lib/rfix/extension/pastel.rb +11 -0
- data/lib/rfix/extension/string.rb +12 -0
- data/lib/rfix/extension/strings.rb +9 -0
- data/lib/rfix/file.rb +6 -41
- data/lib/rfix/file/base.rb +73 -0
- data/lib/rfix/file/deleted.rb +17 -0
- data/lib/rfix/file/ignored.rb +17 -0
- data/lib/rfix/file/tracked.rb +42 -0
- data/lib/rfix/file/untracked.rb +20 -0
- data/lib/rfix/formatter.rb +125 -86
- data/lib/rfix/highlighter.rb +118 -0
- data/lib/rfix/indicator.rb +19 -0
- data/lib/rfix/log.rb +12 -121
- data/lib/rfix/rake/gemfile.rb +111 -0
- data/lib/rfix/rake/paths.rb +25 -23
- data/lib/rfix/rake/support.rb +72 -57
- data/lib/rfix/repository.rb +114 -164
- data/lib/rfix/types.rb +52 -0
- data/lib/rfix/version.rb +1 -1
- data/rfix.gemspec +28 -38
- data/vendor/dry-cli/CHANGELOG.md +191 -0
- data/vendor/dry-cli/CODEOWNERS +1 -0
- data/vendor/dry-cli/CODE_OF_CONDUCT.md +13 -0
- data/vendor/dry-cli/CONTRIBUTING.md +29 -0
- data/vendor/dry-cli/Gemfile +14 -0
- data/vendor/dry-cli/Gemfile.devtools +18 -0
- data/vendor/dry-cli/LICENSE +20 -0
- data/vendor/dry-cli/README.md +29 -0
- data/vendor/dry-cli/Rakefile +13 -0
- data/vendor/dry-cli/bin/console +15 -0
- data/vendor/dry-cli/bin/setup +8 -0
- data/vendor/dry-cli/changelog.yml +97 -0
- data/vendor/dry-cli/docsite/source/arguments.html.md +57 -0
- data/vendor/dry-cli/docsite/source/callbacks.html.md +51 -0
- data/vendor/dry-cli/docsite/source/commands-with-subcommands-and-params.md +86 -0
- data/vendor/dry-cli/docsite/source/commands.html.md +41 -0
- data/vendor/dry-cli/docsite/source/index.html.md +302 -0
- data/vendor/dry-cli/docsite/source/options.html.md +51 -0
- data/vendor/dry-cli/docsite/source/subcommands.html.md +38 -0
- data/vendor/dry-cli/docsite/source/variadic-arguments.html.md +45 -0
- data/vendor/dry-cli/dry-cli.gemspec +36 -0
- data/vendor/dry-cli/lib/dry/cli.rb +224 -0
- data/vendor/dry-cli/lib/dry/cli/banner.rb +135 -0
- data/vendor/dry-cli/lib/dry/cli/command.rb +387 -0
- data/vendor/dry-cli/lib/dry/cli/command_registry.rb +253 -0
- data/vendor/dry-cli/lib/dry/cli/errors.rb +37 -0
- data/vendor/dry-cli/lib/dry/cli/inflector.rb +17 -0
- data/vendor/dry-cli/lib/dry/cli/inline.rb +75 -0
- data/vendor/dry-cli/lib/dry/cli/option.rb +131 -0
- data/vendor/dry-cli/lib/dry/cli/parser.rb +138 -0
- data/vendor/dry-cli/lib/dry/cli/program_name.rb +21 -0
- data/vendor/dry-cli/lib/dry/cli/registry.rb +338 -0
- data/vendor/dry-cli/lib/dry/cli/usage.rb +94 -0
- data/vendor/dry-cli/lib/dry/cli/version.rb +8 -0
- data/vendor/dry-cli/project.yml +13 -0
- data/vendor/dry-cli/spec/integration/commands_spec.rb +14 -0
- data/vendor/dry-cli/spec/integration/inherited_commands_spec.rb +24 -0
- data/vendor/dry-cli/spec/integration/inline_spec.rb +43 -0
- data/vendor/dry-cli/spec/integration/processes_errors_spec.rb +29 -0
- data/vendor/dry-cli/spec/integration/rendering_spec.rb +31 -0
- data/vendor/dry-cli/spec/integration/single_command_spec.rb +81 -0
- data/vendor/dry-cli/spec/integration/subcommands_spec.rb +60 -0
- data/vendor/dry-cli/spec/integration/third_party_gems_spec.rb +18 -0
- data/vendor/dry-cli/spec/spec_helper.rb +15 -0
- data/vendor/dry-cli/spec/support/coverage.rb +15 -0
- data/vendor/dry-cli/spec/support/files.rb +13 -0
- data/vendor/dry-cli/spec/support/fixtures/based +65 -0
- data/vendor/dry-cli/spec/support/fixtures/baz +9 -0
- data/vendor/dry-cli/spec/support/fixtures/baz_command.rb +19 -0
- data/vendor/dry-cli/spec/support/fixtures/foo +588 -0
- data/vendor/dry-cli/spec/support/fixtures/infinites +31 -0
- data/vendor/dry-cli/spec/support/fixtures/inline +20 -0
- data/vendor/dry-cli/spec/support/fixtures/registry.rb +15 -0
- data/vendor/dry-cli/spec/support/fixtures/shared_commands.rb +596 -0
- data/vendor/dry-cli/spec/support/fixtures/with_block.rb +86 -0
- data/vendor/dry-cli/spec/support/fixtures/with_registry.rb +90 -0
- data/vendor/dry-cli/spec/support/fixtures/with_zero_arity_block.rb +87 -0
- data/vendor/dry-cli/spec/support/helpers.rb +37 -0
- data/vendor/dry-cli/spec/support/path.rb +24 -0
- data/vendor/dry-cli/spec/support/rspec.rb +26 -0
- data/vendor/dry-cli/spec/support/rspec_options.rb +16 -0
- data/vendor/dry-cli/spec/support/shared_examples/commands.rb +300 -0
- data/vendor/dry-cli/spec/support/shared_examples/inherited_commands.rb +197 -0
- data/vendor/dry-cli/spec/support/shared_examples/rendering.rb +181 -0
- data/vendor/dry-cli/spec/support/shared_examples/subcommands.rb +226 -0
- data/vendor/dry-cli/spec/support/shared_examples/third_party_gems.rb +49 -0
- data/vendor/dry-cli/spec/support/warnings.rb +10 -0
- data/vendor/dry-cli/spec/unit/dry/cli/cli_spec.rb +123 -0
- data/vendor/dry-cli/spec/unit/dry/cli/inflector_spec.rb +26 -0
- data/vendor/dry-cli/spec/unit/dry/cli/registry_spec.rb +78 -0
- data/vendor/dry-cli/spec/unit/dry/cli/version_spec.rb +7 -0
- data/vendor/strings-ansi/CHANGELOG.md +24 -0
- data/vendor/strings-ansi/CODE_OF_CONDUCT.md +74 -0
- data/vendor/strings-ansi/Gemfile +11 -0
- data/{LICENSE.txt → vendor/strings-ansi/LICENSE.txt} +1 -1
- data/vendor/strings-ansi/README.md +155 -0
- data/vendor/strings-ansi/Rakefile +8 -0
- data/vendor/strings-ansi/appveyor.yml +32 -0
- data/vendor/strings-ansi/bin/console +14 -0
- data/vendor/strings-ansi/bin/setup +8 -0
- data/vendor/strings-ansi/lib/strings-ansi.rb +1 -0
- data/vendor/strings-ansi/lib/strings/ansi.rb +84 -0
- data/vendor/strings-ansi/lib/strings/ansi/extensions.rb +23 -0
- data/vendor/strings-ansi/lib/strings/ansi/version.rb +7 -0
- data/vendor/strings-ansi/spec/fixtures/ansi_codes.yaml +194 -0
- data/vendor/strings-ansi/spec/spec_helper.rb +51 -0
- data/vendor/strings-ansi/spec/unit/ansi_spec.rb +15 -0
- data/vendor/strings-ansi/spec/unit/extensions_spec.rb +19 -0
- data/vendor/strings-ansi/spec/unit/only_ansi_spec.rb +36 -0
- data/vendor/strings-ansi/spec/unit/sanitize_spec.rb +53 -0
- data/vendor/strings-ansi/strings-ansi.gemspec +34 -0
- data/vendor/strings-ansi/tasks/console.rake +11 -0
- data/vendor/strings-ansi/tasks/coverage.rake +11 -0
- data/vendor/strings-ansi/tasks/spec.rake +29 -0
- metadata +274 -188
- data/.github/workflows/main.yml +0 -26
- data/.gitignore +0 -43
- data/.rspec +0 -2
- data/.rubocop.yml +0 -87
- data/.travis.yml +0 -35
- data/Gemfile +0 -2
- data/Gemfile.base +0 -14
- data/Gemfile.base.lock +0 -172
- data/Gemfile.lock +0 -188
- data/Guardfile +0 -16
- data/Makefile +0 -12
- data/README.md +0 -85
- data/Rakefile +0 -31
- data/bin/bundle +0 -114
- data/bin/console +0 -29
- data/bin/guard +0 -29
- data/bin/rake +0 -29
- data/bin/rfix +0 -29
- data/bin/rspec +0 -29
- data/bin/setup +0 -29
- data/ci/Gemfile.rubocop-0.80 +0 -2
- data/ci/Gemfile.rubocop-0.80.lock +0 -170
- data/ci/Gemfile.rubocop-0.81 +0 -2
- data/ci/Gemfile.rubocop-0.81.lock +0 -170
- data/ci/Gemfile.rubocop-0.82 +0 -2
- data/ci/Gemfile.rubocop-0.82.lock +0 -170
- data/ci/Gemfile.rubocop-0.83 +0 -2
- data/ci/Gemfile.rubocop-0.83.lock +0 -168
- data/ci/Gemfile.rubocop-0.84 +0 -2
- data/ci/Gemfile.rubocop-0.84.lock +0 -171
- data/ci/Gemfile.rubocop-0.85 +0 -2
- data/ci/Gemfile.rubocop-0.85.1 +0 -2
- data/ci/Gemfile.rubocop-0.85.1.lock +0 -173
- data/ci/Gemfile.rubocop-0.85.lock +0 -173
- data/lib/rfix/box.rb +0 -112
- data/lib/rfix/branches/base.rb +0 -15
- data/lib/rfix/branches/head.rb +0 -13
- data/lib/rfix/branches/main.rb +0 -28
- data/lib/rfix/branches/name.rb +0 -23
- data/lib/rfix/branches/reference.rb +0 -21
- data/lib/rfix/branches/upstream.rb +0 -13
- data/lib/rfix/cmd.rb +0 -39
- data/lib/rfix/commands/branch.rb +0 -15
- data/lib/rfix/commands/extensions/options.rb +0 -8
- data/lib/rfix/commands/help.rb +0 -7
- data/lib/rfix/commands/helper/args.rb +0 -141
- data/lib/rfix/commands/helper/help.rb +0 -6
- data/lib/rfix/commands/helper/loader.rb +0 -6
- data/lib/rfix/commands/helper/option.rb +0 -0
- data/lib/rfix/commands/helper/params.rb +0 -0
- data/lib/rfix/commands/helper/rubocop.rb +0 -17
- data/lib/rfix/commands/info.rb +0 -30
- data/lib/rfix/commands/lint.rb +0 -22
- data/lib/rfix/commands/local.rb +0 -12
- data/lib/rfix/commands/origin.rb +0 -19
- data/lib/rfix/commands/setup.rb +0 -29
- data/lib/rfix/commands/welcome.rb +0 -24
- data/lib/rfix/deleted.rb +0 -13
- data/lib/rfix/extensions/extensions.rb +0 -18
- data/lib/rfix/extensions/offense.rb +0 -78
- data/lib/rfix/extensions/string.rb +0 -8
- data/lib/rfix/file_cache.rb +0 -59
- data/lib/rfix/git_helper.rb +0 -59
- data/lib/rfix/indentation.rb +0 -39
- data/lib/rfix/loader/bundler.rb +0 -37
- data/lib/rfix/loader/env.rb +0 -33
- data/lib/rfix/loader/spec.rb +0 -41
- data/lib/rfix/no_file.rb +0 -13
- data/lib/rfix/rfix.rb +0 -34
- data/lib/rfix/tracked.rb +0 -72
- data/lib/rfix/tracked_file.rb +0 -16
- data/lib/rfix/untracked.rb +0 -13
- data/resources/ps.png +0 -0
- data/tasks/bump.rake +0 -11
- data/tasks/bundle.rake +0 -17
- data/tasks/complex.rake +0 -54
- data/tasks/execute.rake +0 -38
- data/tasks/libgit2.rake +0 -33
- data/tasks/simple.rake +0 -62
- data/tasks/travis.rake +0 -74
- data/tasks/vendor.rake +0 -34
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
$LOAD_PATH.unshift __dir__ + "/../../lib"
|
|
5
|
+
require "dry/cli"
|
|
6
|
+
require_relative "shared_commands"
|
|
7
|
+
|
|
8
|
+
WithBlock = Dry::CLI.new do |cli|
|
|
9
|
+
cli.register "assets precompile", Commands::Assets::Precompile
|
|
10
|
+
cli.register "console", Commands::Console
|
|
11
|
+
|
|
12
|
+
cli.register "new", Commands::New
|
|
13
|
+
cli.register "routes", Commands::Routes
|
|
14
|
+
cli.register "server", Commands::Server, aliases: ["s"]
|
|
15
|
+
cli.register "version", Commands::Version, aliases: ["v", "-v", "--version"]
|
|
16
|
+
cli.register "exec", Commands::Exec
|
|
17
|
+
|
|
18
|
+
cli.register "hello", Commands::Hello
|
|
19
|
+
cli.register "greeting", Commands::Greeting
|
|
20
|
+
cli.register "sub command", Commands::Sub::Command
|
|
21
|
+
cli.register "with-initializer", Commands::InitializedCommand.new(prop: "prop_val")
|
|
22
|
+
cli.register "root-command", Commands::RootCommand do |prefix|
|
|
23
|
+
prefix.register "sub-command", Commands::RootCommands::SubCommand
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
cli.register "options-with-aliases", Commands::OptionsWithAliases
|
|
27
|
+
cli.register "variadic default", Commands::VariadicArguments
|
|
28
|
+
cli.register "variadic with-mandatory", Commands::MandatoryAndVariadicArguments
|
|
29
|
+
cli.register "variadic with-mandatory-and-options", Commands::MandatoryOptionsAndVariadicArguments
|
|
30
|
+
|
|
31
|
+
cli.register "generate webpack", Webpack::CLI::Generate
|
|
32
|
+
cli.register "hello", Webpack::CLI::Hello
|
|
33
|
+
cli.register "sub command", Webpack::CLI::SubCommand
|
|
34
|
+
cli.register "callbacks", Webpack::CLI::CallbacksCommand
|
|
35
|
+
|
|
36
|
+
cli.register "db" do |prefix|
|
|
37
|
+
prefix.register "apply", Commands::DB::Apply
|
|
38
|
+
prefix.register "console", Commands::DB::Console
|
|
39
|
+
prefix.register "create", Commands::DB::Create
|
|
40
|
+
prefix.register "drop", Commands::DB::Drop
|
|
41
|
+
prefix.register "migrate", Commands::DB::Migrate
|
|
42
|
+
prefix.register "prepare", Commands::DB::Prepare
|
|
43
|
+
prefix.register "version", Commands::DB::Version
|
|
44
|
+
prefix.register "rollback", Commands::DB::Rollback
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
cli.register "destroy", aliases: ["d"] do |prefix|
|
|
48
|
+
prefix.register "action", Commands::Destroy::Action
|
|
49
|
+
prefix.register "app", Commands::Destroy::App
|
|
50
|
+
prefix.register "mailer", Commands::Destroy::Mailer
|
|
51
|
+
prefix.register "migration", Commands::Destroy::Migration
|
|
52
|
+
prefix.register "model", Commands::Destroy::Model
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
cli.register "generate", aliases: ["g"] do |prefix|
|
|
56
|
+
prefix.register "action", Commands::Generate::Action
|
|
57
|
+
prefix.register "app", Commands::Generate::App
|
|
58
|
+
prefix.register "mailer", Commands::Generate::Mailer
|
|
59
|
+
prefix.register "migration", Commands::Generate::Migration
|
|
60
|
+
prefix.register "model", Commands::Generate::Model
|
|
61
|
+
prefix.register "secret", Commands::Generate::Secret
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# we need to be sure that command will not override with nil command
|
|
65
|
+
cli.register "generate webpack", nil
|
|
66
|
+
|
|
67
|
+
cli.before("callbacks") do |args|
|
|
68
|
+
puts "before command callback #{self.class.name} #{args.inspect}"
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
cli.after("callbacks") do |args|
|
|
72
|
+
puts "after command callback #{self.class.name} #{args.inspect}"
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
cli.register "inherited", aliases: ["i"] do |prefix|
|
|
76
|
+
prefix.register "run", InheritedCommands::Run
|
|
77
|
+
prefix.register "subrun", InheritedCommands::SubRun
|
|
78
|
+
prefix.register "logs", InheritedCommands::Logs
|
|
79
|
+
prefix.register "addons", InheritedCommands::Addons
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
cli.before "callbacks", Callbacks::BeforeClass
|
|
83
|
+
cli.after "callbacks", Callbacks::AfterClass
|
|
84
|
+
cli.before "callbacks", Callbacks::Before.new
|
|
85
|
+
cli.after "callbacks", Callbacks::After.new
|
|
86
|
+
end
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
$LOAD_PATH.unshift __dir__ + "/../../lib"
|
|
4
|
+
require "dry/cli"
|
|
5
|
+
require_relative "shared_commands"
|
|
6
|
+
|
|
7
|
+
module Foo
|
|
8
|
+
module CLI
|
|
9
|
+
module Commands
|
|
10
|
+
extend Dry::CLI::Registry
|
|
11
|
+
|
|
12
|
+
register "assets precompile", ::Commands::Assets::Precompile
|
|
13
|
+
register "console", ::Commands::Console
|
|
14
|
+
register "db" do |prefix|
|
|
15
|
+
prefix.register "apply", ::Commands::DB::Apply
|
|
16
|
+
prefix.register "console", ::Commands::DB::Console
|
|
17
|
+
prefix.register "create", ::Commands::DB::Create
|
|
18
|
+
prefix.register "drop", ::Commands::DB::Drop
|
|
19
|
+
prefix.register "migrate", ::Commands::DB::Migrate
|
|
20
|
+
prefix.register "prepare", ::Commands::DB::Prepare
|
|
21
|
+
prefix.register "version", ::Commands::DB::Version
|
|
22
|
+
prefix.register "rollback", ::Commands::DB::Rollback
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
register "destroy", aliases: ["d"] do |prefix|
|
|
26
|
+
prefix.register "action", ::Commands::Destroy::Action
|
|
27
|
+
prefix.register "app", ::Commands::Destroy::App
|
|
28
|
+
prefix.register "mailer", ::Commands::Destroy::Mailer
|
|
29
|
+
prefix.register "migration", ::Commands::Destroy::Migration
|
|
30
|
+
prefix.register "model", ::Commands::Destroy::Model
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
register "generate", aliases: ["g"] do |prefix|
|
|
34
|
+
prefix.register "action", ::Commands::Generate::Action
|
|
35
|
+
prefix.register "app", ::Commands::Generate::App
|
|
36
|
+
prefix.register "mailer", ::Commands::Generate::Mailer
|
|
37
|
+
prefix.register "migration", ::Commands::Generate::Migration
|
|
38
|
+
prefix.register "model", ::Commands::Generate::Model
|
|
39
|
+
prefix.register "secret", ::Commands::Generate::Secret
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
register "inherited", aliases: ["i"] do |prefix|
|
|
43
|
+
prefix.register "run", ::InheritedCommands::Run
|
|
44
|
+
prefix.register "subrun", ::InheritedCommands::SubRun
|
|
45
|
+
prefix.register "logs", ::InheritedCommands::Logs
|
|
46
|
+
prefix.register "addons", ::InheritedCommands::Addons
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
register "new", ::Commands::New
|
|
50
|
+
register "routes", ::Commands::Routes
|
|
51
|
+
register "server", ::Commands::Server, aliases: ["s"]
|
|
52
|
+
register "version", ::Commands::Version, aliases: ["v", "-v", "--version"]
|
|
53
|
+
register "exec", ::Commands::Exec
|
|
54
|
+
|
|
55
|
+
register "hello", ::Commands::Hello
|
|
56
|
+
register "greeting", ::Commands::Greeting
|
|
57
|
+
register "sub command", ::Commands::Sub::Command
|
|
58
|
+
register "with-initializer", ::Commands::InitializedCommand.new(prop: "prop_val")
|
|
59
|
+
register "root-command", ::Commands::RootCommand
|
|
60
|
+
register "root-command sub-command", ::Commands::RootCommands::SubCommand
|
|
61
|
+
|
|
62
|
+
register "options-with-aliases", ::Commands::OptionsWithAliases
|
|
63
|
+
register "variadic default", ::Commands::VariadicArguments
|
|
64
|
+
register "variadic with-mandatory", ::Commands::MandatoryAndVariadicArguments
|
|
65
|
+
register "variadic with-mandatory-and-options", ::Commands::MandatoryOptionsAndVariadicArguments # rubocop:disable Metrics/LineLength
|
|
66
|
+
|
|
67
|
+
register "generate webpack", ::Webpack::CLI::Generate
|
|
68
|
+
register "hello", ::Webpack::CLI::Hello
|
|
69
|
+
register "sub command", ::Webpack::CLI::SubCommand
|
|
70
|
+
register "callbacks", ::Webpack::CLI::CallbacksCommand
|
|
71
|
+
|
|
72
|
+
register "generate webpack", nil
|
|
73
|
+
|
|
74
|
+
before("callbacks") do |args|
|
|
75
|
+
puts "before command callback #{self.class.name} #{args.inspect}"
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
after("callbacks") do |args|
|
|
79
|
+
puts "after command callback #{self.class.name} #{args.inspect}"
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
before("callbacks", ::Callbacks::BeforeClass)
|
|
83
|
+
after("callbacks", ::Callbacks::AfterClass)
|
|
84
|
+
before("callbacks", ::Callbacks::Before.new)
|
|
85
|
+
after("callbacks", ::Callbacks::After.new)
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
WithRegistry = Dry::CLI.new(Foo::CLI::Commands)
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
$LOAD_PATH.unshift __dir__ + "/../../lib"
|
|
5
|
+
require "dry/cli"
|
|
6
|
+
require_relative "shared_commands"
|
|
7
|
+
|
|
8
|
+
WithZeroArityBlock = Dry.CLI do
|
|
9
|
+
register "assets precompile", Commands::Assets::Precompile
|
|
10
|
+
register "console", Commands::Console
|
|
11
|
+
|
|
12
|
+
register "new", Commands::New
|
|
13
|
+
register "routes", Commands::Routes
|
|
14
|
+
register "server", Commands::Server, aliases: ["s"]
|
|
15
|
+
register "version", Commands::Version, aliases: ["v", "-v", "--version"]
|
|
16
|
+
register "exec", Commands::Exec
|
|
17
|
+
|
|
18
|
+
register "hello", Commands::Hello
|
|
19
|
+
register "greeting", Commands::Greeting
|
|
20
|
+
register "sub command", Commands::Sub::Command
|
|
21
|
+
register "with-initializer", Commands::InitializedCommand.new(prop: "prop_val")
|
|
22
|
+
register "root-command", Commands::RootCommand
|
|
23
|
+
register "root-command" do
|
|
24
|
+
register "sub-command", Commands::RootCommands::SubCommand
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
register "options-with-aliases", Commands::OptionsWithAliases
|
|
28
|
+
register "variadic default", Commands::VariadicArguments
|
|
29
|
+
register "variadic with-mandatory", Commands::MandatoryAndVariadicArguments
|
|
30
|
+
register "variadic with-mandatory-and-options", Commands::MandatoryOptionsAndVariadicArguments
|
|
31
|
+
|
|
32
|
+
register "generate webpack", Webpack::CLI::Generate
|
|
33
|
+
register "hello", Webpack::CLI::Hello
|
|
34
|
+
register "sub command", Webpack::CLI::SubCommand
|
|
35
|
+
register "callbacks", Webpack::CLI::CallbacksCommand
|
|
36
|
+
|
|
37
|
+
register "db" do
|
|
38
|
+
register "apply", Commands::DB::Apply
|
|
39
|
+
register "console", Commands::DB::Console
|
|
40
|
+
register "create", Commands::DB::Create
|
|
41
|
+
register "drop", Commands::DB::Drop
|
|
42
|
+
register "migrate", Commands::DB::Migrate
|
|
43
|
+
register "prepare", Commands::DB::Prepare
|
|
44
|
+
register "version", Commands::DB::Version
|
|
45
|
+
register "rollback", Commands::DB::Rollback
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
register "destroy", aliases: ["d"] do
|
|
49
|
+
register "action", Commands::Destroy::Action
|
|
50
|
+
register "app", Commands::Destroy::App
|
|
51
|
+
register "mailer", Commands::Destroy::Mailer
|
|
52
|
+
register "migration", Commands::Destroy::Migration
|
|
53
|
+
register "model", Commands::Destroy::Model
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
register "generate", aliases: ["g"] do
|
|
57
|
+
register "action", Commands::Generate::Action
|
|
58
|
+
register "app", Commands::Generate::App
|
|
59
|
+
register "mailer", Commands::Generate::Mailer
|
|
60
|
+
register "migration", Commands::Generate::Migration
|
|
61
|
+
register "model", Commands::Generate::Model
|
|
62
|
+
register "secret", Commands::Generate::Secret
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
register "inherited", aliases: ["i"] do
|
|
66
|
+
register "run", InheritedCommands::Run
|
|
67
|
+
register "subrun", InheritedCommands::SubRun
|
|
68
|
+
register "logs", InheritedCommands::Logs
|
|
69
|
+
register "addons", InheritedCommands::Addons
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
# we need to be sure that command will not override with nil command
|
|
73
|
+
register "generate webpack", nil
|
|
74
|
+
|
|
75
|
+
before("callbacks") do |args|
|
|
76
|
+
puts "before command callback #{self.class.name} #{args.inspect}"
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
after("callbacks") do |args|
|
|
80
|
+
puts "after command callback #{self.class.name} #{args.inspect}"
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
before "callbacks", Callbacks::BeforeClass
|
|
84
|
+
after "callbacks", Callbacks::AfterClass
|
|
85
|
+
before "callbacks", Callbacks::Before.new
|
|
86
|
+
after "callbacks", Callbacks::After.new
|
|
87
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module RSpec
|
|
4
|
+
module Support
|
|
5
|
+
module Helpers
|
|
6
|
+
def capture_output
|
|
7
|
+
require "stringio"
|
|
8
|
+
output = StringIO.new
|
|
9
|
+
original_stdout = $stdout
|
|
10
|
+
$stdout = output
|
|
11
|
+
yield
|
|
12
|
+
output.string
|
|
13
|
+
rescue SystemExit
|
|
14
|
+
output.string
|
|
15
|
+
ensure
|
|
16
|
+
$stdout = original_stdout
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def capture_error
|
|
20
|
+
require "stringio"
|
|
21
|
+
error = StringIO.new
|
|
22
|
+
original_stderr = $stderr
|
|
23
|
+
$stderr = error
|
|
24
|
+
yield
|
|
25
|
+
error.string
|
|
26
|
+
rescue SystemExit
|
|
27
|
+
error.string
|
|
28
|
+
ensure
|
|
29
|
+
$stderr = original_stderr
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
RSpec.configure do |config|
|
|
36
|
+
config.include(RSpec::Support::Helpers)
|
|
37
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module RSpec
|
|
4
|
+
module Support
|
|
5
|
+
module Path
|
|
6
|
+
def self.included(base)
|
|
7
|
+
base.class_eval do
|
|
8
|
+
before do
|
|
9
|
+
@original_path = ENV["PATH"]
|
|
10
|
+
ENV["PATH"] = __dir__ + "/fixtures:" + ENV["PATH"]
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
after do
|
|
14
|
+
ENV["PATH"] = @original_path
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
RSpec.configure do |config|
|
|
23
|
+
config.include(RSpec::Support::Path)
|
|
24
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
RSpec.configure do |config|
|
|
4
|
+
config.expect_with :rspec do |expectations|
|
|
5
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
config.mock_with :rspec do |mocks|
|
|
9
|
+
mocks.verify_partial_doubles = true
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
config.shared_context_metadata_behavior = :apply_to_host_groups
|
|
13
|
+
|
|
14
|
+
config.filter_run_when_matching :focus
|
|
15
|
+
|
|
16
|
+
config.disable_monkey_patching!
|
|
17
|
+
|
|
18
|
+
config.warnings = true
|
|
19
|
+
|
|
20
|
+
config.default_formatter = "doc" if config.files_to_run.one?
|
|
21
|
+
config.profile_examples = 10
|
|
22
|
+
|
|
23
|
+
config.order = :random
|
|
24
|
+
|
|
25
|
+
Kernel.srand config.seed
|
|
26
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
RSpec.configure do |config|
|
|
2
|
+
# When no filter given, search and run focused tests
|
|
3
|
+
config.filter_run_when_matching :focus
|
|
4
|
+
|
|
5
|
+
# Disables rspec monkey patches (no reason for their existence tbh)
|
|
6
|
+
config.disable_monkey_patching!
|
|
7
|
+
|
|
8
|
+
# Run ruby in verbose mode
|
|
9
|
+
config.warnings = true
|
|
10
|
+
|
|
11
|
+
# Collect all failing expectations automatically,
|
|
12
|
+
# without calling aggregate_failures everywhere
|
|
13
|
+
config.define_derived_metadata do |meta|
|
|
14
|
+
meta[:aggregate_failures] = true
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# rubocop:disable Metrics/LineLength
|
|
4
|
+
RSpec.shared_examples "Commands" do |cli|
|
|
5
|
+
let(:cli) { cli }
|
|
6
|
+
|
|
7
|
+
let(:cmd) { File.basename($PROGRAM_NAME, File.extname($PROGRAM_NAME)) }
|
|
8
|
+
|
|
9
|
+
it "calls basic command" do
|
|
10
|
+
output = capture_output { cli.call(arguments: ["version"]) }
|
|
11
|
+
expect(output).to eq("v1.0.0\n")
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
it "calls basic command with alias" do
|
|
15
|
+
output = capture_output { cli.call(arguments: ["v"]) }
|
|
16
|
+
expect(output).to eq("v1.0.0\n")
|
|
17
|
+
|
|
18
|
+
output = capture_output { cli.call(arguments: ["-v"]) }
|
|
19
|
+
expect(output).to eq("v1.0.0\n")
|
|
20
|
+
|
|
21
|
+
output = capture_output { cli.call(arguments: ["--version"]) }
|
|
22
|
+
expect(output).to eq("v1.0.0\n")
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
it "calls subcommand via intermediate alias" do
|
|
26
|
+
output = capture_output { cli.call(arguments: %w[g secret web]) }
|
|
27
|
+
expect(output).to eq("generate secret - app: web\n")
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
context "works with params" do
|
|
31
|
+
it "without params" do
|
|
32
|
+
output = capture_output { cli.call(arguments: ["server"]) }
|
|
33
|
+
expect(output).to eq("server - {:code_reloading=>true, :deps=>[\"dep1\", \"dep2\"]}\n")
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
it "a param using space" do
|
|
37
|
+
output = capture_output { cli.call(arguments: %w[server --server thin]) }
|
|
38
|
+
expect(output).to eq("server - {:code_reloading=>true, :deps=>[\"dep1\", \"dep2\"], :server=>\"thin\"}\n")
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
it "a param using equal sign" do
|
|
42
|
+
output = capture_output { cli.call(arguments: %w[server --host=localhost]) }
|
|
43
|
+
expect(output).to eq("server - {:code_reloading=>true, :deps=>[\"dep1\", \"dep2\"], :host=>\"localhost\"}\n")
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
it "a param using alias" do
|
|
47
|
+
output = capture_output { cli.call(arguments: %w[options-with-aliases -u test]) }
|
|
48
|
+
expect(output).to eq("options with aliases - {:opt=>false, :url=>\"test\"}\n")
|
|
49
|
+
|
|
50
|
+
output = capture_output { cli.call(arguments: %w[options-with-aliases -utest]) }
|
|
51
|
+
expect(output).to eq("options with aliases - {:opt=>false, :url=>\"test\"}\n")
|
|
52
|
+
|
|
53
|
+
output = capture_output { cli.call(arguments: %w[options-with-aliases -f -u test]) }
|
|
54
|
+
expect(output).to eq("options with aliases - {:opt=>false, :flag=>true, :url=>\"test\"}\n")
|
|
55
|
+
|
|
56
|
+
output = capture_output { cli.call(arguments: %w[options-with-aliases -o]) }
|
|
57
|
+
expect(output).to eq("options with aliases - {:opt=>true}\n")
|
|
58
|
+
|
|
59
|
+
output = capture_output { cli.call(arguments: %w[options-with-aliases -of]) }
|
|
60
|
+
expect(output).to eq("options with aliases - {:opt=>true, :flag=>true}\n")
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
it "a param with unknown param" do
|
|
64
|
+
error = capture_error { cli.call(arguments: %w[server --unknown 1234]) }
|
|
65
|
+
expect(error).to eq("ERROR: \"rspec server\" was called with arguments \"--unknown 1234\"\n")
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
it "with boolean param" do
|
|
69
|
+
output = capture_output { cli.call(arguments: ["server"]) }
|
|
70
|
+
expect(output).to eq("server - {:code_reloading=>true, :deps=>[\"dep1\", \"dep2\"]}\n")
|
|
71
|
+
|
|
72
|
+
output = capture_output { cli.call(arguments: %w[server --no-code-reloading]) }
|
|
73
|
+
expect(output).to eq("server - {:code_reloading=>false, :deps=>[\"dep1\", \"dep2\"]}\n")
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
context "with array param" do
|
|
77
|
+
it "allows to omit optional array argument" do
|
|
78
|
+
output = capture_output { cli.call(arguments: %w[exec test]) }
|
|
79
|
+
expect(output).to eq("exec - Task: test - Directories: []\n")
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
it "capture all the remaining arguments" do
|
|
83
|
+
output = capture_output { cli.call(arguments: %w[exec test api admin]) }
|
|
84
|
+
expect(output).to eq("exec - Task: test - Directories: [\"api\", \"admin\"]\n")
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
context "with supported values" do
|
|
89
|
+
context "and with supported value passed" do
|
|
90
|
+
it "call the command with the option" do
|
|
91
|
+
output = capture_output { cli.call(arguments: %w[console --engine=pry]) }
|
|
92
|
+
expect(output).to eq("console - engine: pry\n")
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
context "and with an unknown value passed" do
|
|
97
|
+
it "prints error" do
|
|
98
|
+
error = capture_error { cli.call(arguments: %w[console --engine=unknown]) }
|
|
99
|
+
expect(error).to eq("ERROR: \"rspec console\" was called with arguments \"--engine=unknown\"\n") # rubocop:disable Metrics/LineLength
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
it "with help param" do
|
|
105
|
+
output = capture_output { cli.call(arguments: %w[server --help]) }
|
|
106
|
+
|
|
107
|
+
expected = <<~DESC
|
|
108
|
+
Command:
|
|
109
|
+
#{cmd} server
|
|
110
|
+
|
|
111
|
+
Usage:
|
|
112
|
+
#{cmd} server
|
|
113
|
+
|
|
114
|
+
Description:
|
|
115
|
+
Start Foo server (only for development)
|
|
116
|
+
|
|
117
|
+
Options:
|
|
118
|
+
--server=VALUE # Force a server engine (eg, webrick, puma, thin, etc..)
|
|
119
|
+
--host=VALUE # The host address to bind to
|
|
120
|
+
--port=VALUE, -p VALUE # The port to run the server on
|
|
121
|
+
--debug=VALUE # Turn on debug output
|
|
122
|
+
--warn=VALUE # Turn on warnings
|
|
123
|
+
--daemonize=VALUE # Daemonize the server
|
|
124
|
+
--pid=VALUE # Path to write a pid file after daemonize
|
|
125
|
+
--[no-]code-reloading # Code reloading, default: true
|
|
126
|
+
--deps=VALUE1,VALUE2,.. # List of extra dependencies, default: ["dep1", "dep2"]
|
|
127
|
+
--help, -h # Print this help
|
|
128
|
+
|
|
129
|
+
Examples:
|
|
130
|
+
#{cmd} server # Basic usage (it uses the bundled server engine)
|
|
131
|
+
#{cmd} server --server=webrick # Force `webrick` server engine
|
|
132
|
+
#{cmd} server --host=0.0.0.0 # Bind to a host
|
|
133
|
+
#{cmd} server --port=2306 # Bind to a port
|
|
134
|
+
#{cmd} server --no-code-reloading # Disable code reloading
|
|
135
|
+
DESC
|
|
136
|
+
|
|
137
|
+
expect(output).to eq(expected)
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
context "with required params" do
|
|
141
|
+
it "can be used" do
|
|
142
|
+
output = capture_output { cli.call(arguments: %w[new bookshelf]) }
|
|
143
|
+
expect(output).to eq("new - project: bookshelf\n")
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
it "with unknown param" do
|
|
147
|
+
error = capture_error { cli.call(arguments: %w[new bookshelf --unknown 1234]) }
|
|
148
|
+
expect(error).to eq("ERROR: \"rspec new\" was called with arguments \"bookshelf --unknown 1234\"\n") # rubocop:disable Metrics/LineLength
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
it "no required" do
|
|
152
|
+
output = capture_output { cli.call(arguments: %w[generate secret web]) }
|
|
153
|
+
expect(output).to eq("generate secret - app: web\n")
|
|
154
|
+
|
|
155
|
+
output = capture_output { cli.call(arguments: %w[generate secret]) }
|
|
156
|
+
expect(output).to eq("generate secret - app: \n")
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
it "an error is displayed if there aren't required params" do
|
|
160
|
+
error = capture_error { cli.call(arguments: ["new"]) }
|
|
161
|
+
expected_error = <<~DESC
|
|
162
|
+
ERROR: "#{cmd} new" was called with no arguments
|
|
163
|
+
Usage: "#{cmd} new PROJECT"
|
|
164
|
+
DESC
|
|
165
|
+
expect(error).to eq(expected_error)
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
it "with default value and using options" do
|
|
169
|
+
output = capture_output { cli.call(arguments: %w[greeting --person=Alfonso]) }
|
|
170
|
+
expect(output).to eq("response: Hello World, person: Alfonso\n")
|
|
171
|
+
|
|
172
|
+
output = capture_output { cli.call(arguments: %w[greeting bye --person=Alfonso]) }
|
|
173
|
+
expect(output).to eq("response: bye, person: Alfonso\n")
|
|
174
|
+
end
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
context "with extra params" do
|
|
178
|
+
it "is accessible via options[:args]" do
|
|
179
|
+
output = capture_output { cli.call(arguments: %w[variadic default bar baz]) }
|
|
180
|
+
expect(output).to eq("Unused Arguments: bar, baz\n")
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
context "when there is a required argument" do
|
|
184
|
+
it "parses both separately" do
|
|
185
|
+
output = capture_output { cli.call(arguments: ["variadic", "with-mandatory", cmd, "bar", "baz"]) }
|
|
186
|
+
expect(output).to eq("first: #{cmd}\nUnused Arguments: bar, baz\n")
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
context "and there are options" do
|
|
190
|
+
it "parses both separately" do
|
|
191
|
+
output = capture_output { cli.call(arguments: ["variadic", "with-mandatory-and-options", cmd, "bar", "baz"]) }
|
|
192
|
+
expect(output).to eq("first: #{cmd}\nurl: \nmethod: \nUnused Arguments: bar, baz\n")
|
|
193
|
+
|
|
194
|
+
output = capture_output { cli.call(arguments: ["variadic", "with-mandatory-and-options", "--url=root", "--method=index", cmd, "bar", "baz"]) }
|
|
195
|
+
expect(output).to eq("first: #{cmd}\nurl: root\nmethod: index\nUnused Arguments: bar, baz\n")
|
|
196
|
+
|
|
197
|
+
output = capture_output { cli.call(arguments: %w[variadic with-mandatory-and-options uno -- due tre --blah]) }
|
|
198
|
+
expect(output).to eq("first: uno\nurl: \nmethod: \nUnused Arguments: due, tre, --blah\n")
|
|
199
|
+
end
|
|
200
|
+
end
|
|
201
|
+
end
|
|
202
|
+
end
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
context "works with command with arguments and subcommands" do
|
|
206
|
+
it "shows help" do
|
|
207
|
+
output = capture_output { cli.call(arguments: %w[root-command -h]) }
|
|
208
|
+
expected = <<~DESC
|
|
209
|
+
Command:
|
|
210
|
+
#{cmd} root-command
|
|
211
|
+
|
|
212
|
+
Usage:
|
|
213
|
+
#{cmd} root-command ROOT_COMMAND_ARGUMENT | #{cmd} root-command SUBCOMMAND
|
|
214
|
+
|
|
215
|
+
Description:
|
|
216
|
+
Root command with arguments and subcommands
|
|
217
|
+
|
|
218
|
+
Subcommands:
|
|
219
|
+
sub-command # Root command sub command
|
|
220
|
+
|
|
221
|
+
Arguments:
|
|
222
|
+
ROOT_COMMAND_ARGUMENT # REQUIRED Root command argument
|
|
223
|
+
|
|
224
|
+
Options:
|
|
225
|
+
--root-command-option=VALUE # Root command option
|
|
226
|
+
--help, -h # Print this help
|
|
227
|
+
DESC
|
|
228
|
+
|
|
229
|
+
expect(output).to eq(expected)
|
|
230
|
+
|
|
231
|
+
output = capture_output { cli.call(arguments: %w[root-command --help]) }
|
|
232
|
+
expect(output).to eq(expected)
|
|
233
|
+
end
|
|
234
|
+
|
|
235
|
+
context "works with params" do
|
|
236
|
+
it "without params" do
|
|
237
|
+
error = capture_error { cli.call(arguments: %w[root-command]) }
|
|
238
|
+
expected = <<~DESC
|
|
239
|
+
ERROR: "rspec root-command" was called with no arguments
|
|
240
|
+
Usage: "rspec root-command ROOT_COMMAND_ARGUMENT | rspec root-command SUBCOMMAND"
|
|
241
|
+
DESC
|
|
242
|
+
|
|
243
|
+
expect(error).to eq(expected)
|
|
244
|
+
end
|
|
245
|
+
|
|
246
|
+
it "with params" do
|
|
247
|
+
output = capture_output {
|
|
248
|
+
cli.call(arguments: ["root-command", '"hello world"'])
|
|
249
|
+
}
|
|
250
|
+
expected = <<~DESC
|
|
251
|
+
I'm a root-command argument:"hello world"
|
|
252
|
+
I'm a root-command option:
|
|
253
|
+
DESC
|
|
254
|
+
|
|
255
|
+
expect(output).to eq(expected)
|
|
256
|
+
end
|
|
257
|
+
|
|
258
|
+
it "with option using space" do
|
|
259
|
+
output = capture_output {
|
|
260
|
+
cli.call(arguments: [
|
|
261
|
+
"root-command",
|
|
262
|
+
'"hello world"',
|
|
263
|
+
"--root-command-option",
|
|
264
|
+
'"bye world"'
|
|
265
|
+
])
|
|
266
|
+
}
|
|
267
|
+
expected = <<~DESC
|
|
268
|
+
I'm a root-command argument:"hello world"
|
|
269
|
+
I'm a root-command option:"bye world"
|
|
270
|
+
DESC
|
|
271
|
+
|
|
272
|
+
expect(output).to eq(expected)
|
|
273
|
+
end
|
|
274
|
+
|
|
275
|
+
it "with option using equal sign" do
|
|
276
|
+
output = capture_output {
|
|
277
|
+
cli.call(arguments: [
|
|
278
|
+
"root-command",
|
|
279
|
+
'"hello world"',
|
|
280
|
+
'--root-command-option="bye world"'
|
|
281
|
+
])
|
|
282
|
+
}
|
|
283
|
+
expected = <<~DESC
|
|
284
|
+
I'm a root-command argument:"hello world"
|
|
285
|
+
I'm a root-command option:"bye world"
|
|
286
|
+
DESC
|
|
287
|
+
|
|
288
|
+
expect(output).to eq(expected)
|
|
289
|
+
end
|
|
290
|
+
end
|
|
291
|
+
end
|
|
292
|
+
|
|
293
|
+
context "works with instances of commands" do
|
|
294
|
+
it "executes instance" do
|
|
295
|
+
output = capture_output { cli.call(arguments: %w[with-initializer]) }
|
|
296
|
+
expect(output).to eq("The value of prop is prop_val\n")
|
|
297
|
+
end
|
|
298
|
+
end
|
|
299
|
+
end
|
|
300
|
+
# rubocop:enable Metrics/LineLength
|