rfix 1.4.1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- 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,31 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
$LOAD_PATH.unshift __dir__ + "/../../lib"
|
5
|
+
require "dry/cli"
|
6
|
+
|
7
|
+
module Infinites
|
8
|
+
extend Dry::CLI::Registry
|
9
|
+
|
10
|
+
class Reader < Dry::CLI::Command
|
11
|
+
def call(*)
|
12
|
+
while (a = $stdin.gets)
|
13
|
+
puts "From stdin: #{a}"
|
14
|
+
sleep 2
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
class Writer < Dry::CLI::Command
|
20
|
+
def call(*)
|
21
|
+
(0..Float::INFINITY).each do |i|
|
22
|
+
$stdout.puts i
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
register "reader", Reader
|
28
|
+
register "writer", Writer
|
29
|
+
end
|
30
|
+
|
31
|
+
Dry.CLI(Infinites).call
|
@@ -0,0 +1,20 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
$LOAD_PATH.unshift __dir__ + "/../../../lib"
|
5
|
+
require "dry/cli"
|
6
|
+
require_relative "../../../lib/dry/cli/inline"
|
7
|
+
|
8
|
+
desc "Baz command line interface"
|
9
|
+
argument :mandatory_arg, required: true, aliases: %w[m], desc: "Mandatory argument"
|
10
|
+
argument :optional_arg, aliases: %w[o],
|
11
|
+
desc: "Optional argument (has to have default value in call method)"
|
12
|
+
option :option_one, aliases: %w[1], desc: "Option one"
|
13
|
+
option :boolean_option, aliases: %w[b], desc: "Option boolean", type: :boolean
|
14
|
+
option :option_with_default, aliases: %w[d], desc: "Option default", default: "test"
|
15
|
+
|
16
|
+
run do |mandatory_arg:, optional_arg: "optional_arg", **options|
|
17
|
+
puts "mandatory_arg: #{mandatory_arg}. " \
|
18
|
+
"optional_arg: #{optional_arg}. " \
|
19
|
+
"Options: #{options.inspect}"
|
20
|
+
end
|
@@ -0,0 +1,596 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# rubocop:disable Metrics/LineLength
|
4
|
+
module Commands
|
5
|
+
class Command < Dry::CLI::Command
|
6
|
+
end
|
7
|
+
|
8
|
+
module Assets
|
9
|
+
class Precompile < Dry::CLI::Command
|
10
|
+
desc "Precompile assets for deployment"
|
11
|
+
|
12
|
+
example [
|
13
|
+
"FOO_ENV=production # Precompile assets for production environment"
|
14
|
+
]
|
15
|
+
|
16
|
+
def call(*); end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
class Console < Dry::CLI::Command
|
21
|
+
desc "Starts Foo console"
|
22
|
+
option :engine, desc: "Force a console engine", values: %w[irb pry ripl]
|
23
|
+
|
24
|
+
example [
|
25
|
+
" # Uses the bundled engine",
|
26
|
+
"--engine=pry # Force to use Pry"
|
27
|
+
]
|
28
|
+
|
29
|
+
def call(engine: nil, **)
|
30
|
+
puts "console - engine: #{engine}"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
module DB
|
35
|
+
class Apply < Dry::CLI::Command
|
36
|
+
desc "Migrate, dump the SQL schema, and delete the migrations (experimental)"
|
37
|
+
|
38
|
+
def call(*); end
|
39
|
+
end
|
40
|
+
|
41
|
+
class Console < Dry::CLI::Command
|
42
|
+
desc "Starts a database console"
|
43
|
+
|
44
|
+
def call(*); end
|
45
|
+
end
|
46
|
+
|
47
|
+
class Create < Dry::CLI::Command
|
48
|
+
desc "Create the database (only for development/test)"
|
49
|
+
|
50
|
+
def call(*); end
|
51
|
+
end
|
52
|
+
|
53
|
+
class Drop < Dry::CLI::Command
|
54
|
+
desc "Drop the database (only for development/test)"
|
55
|
+
|
56
|
+
def call(*); end
|
57
|
+
end
|
58
|
+
|
59
|
+
class Migrate < Dry::CLI::Command
|
60
|
+
desc "Migrate the database"
|
61
|
+
argument :version, desc: "The target version of the migration (see `foo db version`)"
|
62
|
+
|
63
|
+
example [
|
64
|
+
" # Migrate to the last version",
|
65
|
+
"20170721120747 # Migrate to a specific version"
|
66
|
+
]
|
67
|
+
|
68
|
+
def call(*); end
|
69
|
+
end
|
70
|
+
|
71
|
+
class Prepare < Dry::CLI::Command
|
72
|
+
desc "Drop, create, and migrate the database (only for development/test)"
|
73
|
+
|
74
|
+
def call(*); end
|
75
|
+
end
|
76
|
+
|
77
|
+
class Version < Dry::CLI::Command
|
78
|
+
desc "Print the current migrated version"
|
79
|
+
|
80
|
+
def call(*); end
|
81
|
+
end
|
82
|
+
|
83
|
+
class Rollback < Dry::CLI::Command
|
84
|
+
desc "Rollback the database"
|
85
|
+
|
86
|
+
argument :steps, desc: "Number of versions to rollback", default: 1
|
87
|
+
|
88
|
+
def call(steps:, **)
|
89
|
+
puts steps
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
module Destroy
|
95
|
+
class Action < Dry::CLI::Command
|
96
|
+
desc "Destroy an action from app"
|
97
|
+
|
98
|
+
example [
|
99
|
+
"web home#index # Basic usage",
|
100
|
+
"admin users#index # Destroy from `admin` app"
|
101
|
+
]
|
102
|
+
|
103
|
+
argument :app, required: true, desc: "The application name (eg. `web`)"
|
104
|
+
argument :action, required: true, desc: "The action name (eg. `home#index`)"
|
105
|
+
|
106
|
+
def call(app:, action:, **)
|
107
|
+
puts "destroy action - app: #{app}, action: #{action}"
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
class App < Dry::CLI::Command
|
112
|
+
desc "Destroy an app"
|
113
|
+
|
114
|
+
argument :app, required: true, desc: "The application name (eg. `web`)"
|
115
|
+
|
116
|
+
example [
|
117
|
+
"admin # Destroy `admin` app"
|
118
|
+
]
|
119
|
+
|
120
|
+
def call(*); end
|
121
|
+
end
|
122
|
+
|
123
|
+
class Mailer < Dry::CLI::Command
|
124
|
+
desc "Destroy a mailer"
|
125
|
+
|
126
|
+
argument :mailer, required: true, desc: "The mailer name (eg. `welcome`)"
|
127
|
+
|
128
|
+
example [
|
129
|
+
"welcome # Destroy `WelcomeMailer` mailer"
|
130
|
+
]
|
131
|
+
|
132
|
+
def call(*); end
|
133
|
+
end
|
134
|
+
|
135
|
+
class Migration < Dry::CLI::Command
|
136
|
+
desc "Destroy a migration"
|
137
|
+
|
138
|
+
argument :migration, required: true, desc: "The migration name (eg. `create_users`)"
|
139
|
+
|
140
|
+
example [
|
141
|
+
"create_users # Destroy `db/migrations/20170721120747_create_users.rb`"
|
142
|
+
]
|
143
|
+
|
144
|
+
def call(*); end
|
145
|
+
end
|
146
|
+
|
147
|
+
class Model < Dry::CLI::Command
|
148
|
+
desc "Destroy a model"
|
149
|
+
|
150
|
+
argument :model, required: true, desc: "The model name (eg. `user`)"
|
151
|
+
|
152
|
+
example [
|
153
|
+
"user # Destroy `User` entity and `UserRepository` repository"
|
154
|
+
]
|
155
|
+
|
156
|
+
def call(*); end
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
module Generate
|
161
|
+
class Action < Dry::CLI::Command
|
162
|
+
desc "Generate an action for app"
|
163
|
+
|
164
|
+
example [
|
165
|
+
"web home#index # Basic usage",
|
166
|
+
"admin home#index # Generate for `admin` app",
|
167
|
+
"web home#index --url=/ # Specify URL",
|
168
|
+
"web sessions#destroy --method=GET # Specify HTTP method",
|
169
|
+
"web books#create --skip-view # Skip view and template"
|
170
|
+
]
|
171
|
+
|
172
|
+
argument :app, required: true, desc: "The application name (eg. `web`)"
|
173
|
+
argument :action, required: true, desc: "The action name (eg. `home#index`)"
|
174
|
+
|
175
|
+
option :url, desc: "The action URL"
|
176
|
+
option :method, desc: "The action HTTP method"
|
177
|
+
option :skip_view, type: :boolean, default: false, desc: "Skip view and template"
|
178
|
+
|
179
|
+
def call(app:, action:, **options)
|
180
|
+
puts "generate action - app: #{app}, action: #{action}, options: #{options.inspect}"
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
class App < Dry::CLI::Command
|
185
|
+
desc "Generate an app"
|
186
|
+
|
187
|
+
argument :app, required: true, desc: "The application name (eg. `web`)"
|
188
|
+
option :application_base_url, desc: "The app base URL (eg. `/api/v1`)"
|
189
|
+
|
190
|
+
example [
|
191
|
+
"admin # Generate `admin` app",
|
192
|
+
"api --application-base-url=/api/v1 # Generate `api` app and mount at `/api/v1`"
|
193
|
+
]
|
194
|
+
|
195
|
+
def call(*); end
|
196
|
+
end
|
197
|
+
|
198
|
+
class Mailer < Dry::CLI::Command
|
199
|
+
desc "Generate a mailer"
|
200
|
+
|
201
|
+
argument :mailer, required: true, desc: "The mailer name (eg. `welcome`)"
|
202
|
+
|
203
|
+
option :from, desc: "The default `from` field of the mail"
|
204
|
+
option :to, desc: "The default `to` field of the mail"
|
205
|
+
option :subject, desc: "The mail subject"
|
206
|
+
|
207
|
+
example [
|
208
|
+
"welcome # Basic usage",
|
209
|
+
'welcome --from="noreply@example.com" # Generate with default `from` value',
|
210
|
+
'announcement --to="users@example.com" # Generate with default `to` value',
|
211
|
+
'forgot_password --subject="Your password reset" # Generate with default `subject`'
|
212
|
+
]
|
213
|
+
|
214
|
+
def call(*); end
|
215
|
+
end
|
216
|
+
|
217
|
+
class Migration < Dry::CLI::Command
|
218
|
+
desc "Generate a migration"
|
219
|
+
|
220
|
+
argument :migration, required: true, desc: "The migration name (eg. `create_users`)"
|
221
|
+
|
222
|
+
example [
|
223
|
+
"create_users # Generate `db/migrations/20170721120747_create_users.rb`"
|
224
|
+
]
|
225
|
+
|
226
|
+
def call(*); end
|
227
|
+
end
|
228
|
+
|
229
|
+
class Model < Dry::CLI::Command
|
230
|
+
desc "Generate a model"
|
231
|
+
|
232
|
+
argument :model, required: true, desc: "Model name (eg. `user`)"
|
233
|
+
option :skip_migration, type: :boolean, default: false, desc: "Skip migration"
|
234
|
+
|
235
|
+
example [
|
236
|
+
"user # Generate `User` entity, `UserRepository` repository, and the migration",
|
237
|
+
"user --skip-migration # Generate `User` entity and `UserRepository` repository"
|
238
|
+
]
|
239
|
+
|
240
|
+
def call(model:, **)
|
241
|
+
puts "generate model - model: #{model}"
|
242
|
+
end
|
243
|
+
end
|
244
|
+
|
245
|
+
class Secret < Dry::CLI::Command
|
246
|
+
desc "Generate session secret"
|
247
|
+
|
248
|
+
argument :app, desc: "The application name (eg. `web`)"
|
249
|
+
|
250
|
+
example [
|
251
|
+
" # Prints secret (eg. `6fad60e21f3f6bfcaf8e56cdb0f835d644b4892c3badc58328126812429bf073`)",
|
252
|
+
"web # Prints session secret (eg. `WEB_SESSIONS_SECRET=6fad60e21f3f6bfcaf8e56cdb0f835d644b4892c3badc58328126812429bf073`)"
|
253
|
+
]
|
254
|
+
|
255
|
+
def call(app: nil, **)
|
256
|
+
puts "generate secret - app: #{app}"
|
257
|
+
end
|
258
|
+
end
|
259
|
+
end
|
260
|
+
|
261
|
+
class New < Dry::CLI::Command
|
262
|
+
desc "Generate a new Foo project"
|
263
|
+
argument :project, required: true
|
264
|
+
|
265
|
+
option :database, desc: "Database (sqlite/postgres/mysql)", default: "sqlite", aliases: ["-d", "--db"]
|
266
|
+
option :application_name, desc: "App name", default: "web"
|
267
|
+
option :application_base_url, desc: "App base URL", default: "/"
|
268
|
+
option :template, desc: "Template engine (erb/haml/slim)", default: "erb"
|
269
|
+
option :test, desc: "Project testing framework (minitest/rspec)", default: "minitest"
|
270
|
+
option :foo_head, desc: "Use Foo HEAD (true/false)", type: :boolean, default: false
|
271
|
+
|
272
|
+
example [
|
273
|
+
"bookshelf # Basic usage",
|
274
|
+
"bookshelf --test=rspec # Setup RSpec testing framework",
|
275
|
+
"bookshelf --database=postgres # Setup Postgres database",
|
276
|
+
"bookshelf --template=slim # Setup Slim template engine",
|
277
|
+
"bookshelf --foo-head # Use Foo HEAD"
|
278
|
+
]
|
279
|
+
|
280
|
+
def call(project:, **)
|
281
|
+
puts "new - project: #{project}"
|
282
|
+
end
|
283
|
+
end
|
284
|
+
|
285
|
+
class Routes < Dry::CLI::Command
|
286
|
+
desc "Print routes"
|
287
|
+
|
288
|
+
def call(*); end
|
289
|
+
end
|
290
|
+
|
291
|
+
class Server < Dry::CLI::Command
|
292
|
+
desc "Start Foo server (only for development)"
|
293
|
+
|
294
|
+
option :server, desc: "Force a server engine (eg, webrick, puma, thin, etc..)"
|
295
|
+
option :host, desc: "The host address to bind to"
|
296
|
+
option :port, desc: "The port to run the server on", aliases: ["-p", "p", "--p"]
|
297
|
+
option :debug, desc: "Turn on debug output"
|
298
|
+
option :warn, desc: "Turn on warnings"
|
299
|
+
option :daemonize, desc: "Daemonize the server"
|
300
|
+
option :pid, desc: "Path to write a pid file after daemonize"
|
301
|
+
option :code_reloading, desc: "Code reloading", type: :boolean, default: true
|
302
|
+
option :deps, desc: "List of extra dependencies", type: :array, default: %w[dep1 dep2]
|
303
|
+
|
304
|
+
example [
|
305
|
+
" # Basic usage (it uses the bundled server engine)",
|
306
|
+
"--server=webrick # Force `webrick` server engine",
|
307
|
+
"--host=0.0.0.0 # Bind to a host",
|
308
|
+
"--port=2306 # Bind to a port",
|
309
|
+
"--no-code-reloading # Disable code reloading"
|
310
|
+
]
|
311
|
+
|
312
|
+
def call(**options)
|
313
|
+
puts "server - #{options.inspect}"
|
314
|
+
end
|
315
|
+
end
|
316
|
+
|
317
|
+
class Version < Dry::CLI::Command
|
318
|
+
desc "Print Foo version"
|
319
|
+
|
320
|
+
def call(*)
|
321
|
+
puts "v1.0.0"
|
322
|
+
end
|
323
|
+
end
|
324
|
+
|
325
|
+
class Exec < Dry::CLI::Command
|
326
|
+
desc "Execute a task"
|
327
|
+
|
328
|
+
argument :task, desc: "Task to execute", type: :string, required: true
|
329
|
+
argument :dirs, desc: "Directories", type: :array, required: false
|
330
|
+
|
331
|
+
def call(task:, dirs: [], **)
|
332
|
+
puts "exec - Task: #{task} - Directories: #{dirs.inspect}"
|
333
|
+
end
|
334
|
+
end
|
335
|
+
|
336
|
+
class Hello < Dry::CLI::Command
|
337
|
+
def call(*)
|
338
|
+
raise NotImplementedError
|
339
|
+
end
|
340
|
+
end
|
341
|
+
|
342
|
+
class Greeting < Dry::CLI::Command
|
343
|
+
argument :response, default: "Hello World"
|
344
|
+
|
345
|
+
option :person
|
346
|
+
|
347
|
+
def call(response:, **options)
|
348
|
+
puts "response: #{response}, person: #{options[:person]}"
|
349
|
+
end
|
350
|
+
end
|
351
|
+
|
352
|
+
class VariadicArguments < Dry::CLI::Command
|
353
|
+
desc "accept multiple arguments at the end of the command"
|
354
|
+
|
355
|
+
def call(**options)
|
356
|
+
puts "Unused Arguments: #{options[:args].join(", ")}"
|
357
|
+
end
|
358
|
+
end
|
359
|
+
|
360
|
+
class MandatoryAndVariadicArguments < Dry::CLI::Command
|
361
|
+
desc "require one command and accept multiple unused arguments"
|
362
|
+
|
363
|
+
argument :first, desc: "mandatory first argument", required: true
|
364
|
+
|
365
|
+
def call(first:, **options)
|
366
|
+
puts "first: #{first}"
|
367
|
+
puts "Unused Arguments: #{options[:args].join(", ")}"
|
368
|
+
end
|
369
|
+
end
|
370
|
+
|
371
|
+
class MandatoryOptionsAndVariadicArguments < Dry::CLI::Command
|
372
|
+
desc "require one command, accept options and multiple unused arguments"
|
373
|
+
|
374
|
+
argument :first, desc: "mandatory first argument", required: true
|
375
|
+
option :url, desc: "The action URL"
|
376
|
+
option :method, desc: "The action HTTP method"
|
377
|
+
|
378
|
+
def call(first:, **options)
|
379
|
+
puts "first: #{first}"
|
380
|
+
puts "url: #{options[:url]}"
|
381
|
+
puts "method: #{options[:method]}"
|
382
|
+
puts "Unused Arguments: #{options[:args].join(", ")}"
|
383
|
+
end
|
384
|
+
end
|
385
|
+
|
386
|
+
class OptionsWithAliases < Dry::CLI::Command
|
387
|
+
desc "Accepts options with aliases"
|
388
|
+
|
389
|
+
option :url, desc: "The action URL", aliases: %w[-u u --u]
|
390
|
+
option :flag, desc: "The flag", type: :boolean, aliases: %w[f]
|
391
|
+
option :opt, desc: "The opt", type: :boolean, aliases: %w[o], default: false
|
392
|
+
|
393
|
+
def call(**options)
|
394
|
+
puts "options with aliases - #{options.inspect}"
|
395
|
+
end
|
396
|
+
end
|
397
|
+
|
398
|
+
module Sub
|
399
|
+
class Command < Dry::CLI::Command
|
400
|
+
def call(*)
|
401
|
+
raise NotImplementedError
|
402
|
+
end
|
403
|
+
end
|
404
|
+
end
|
405
|
+
|
406
|
+
class RootCommand < Dry::CLI::Command
|
407
|
+
desc "Root command with arguments and subcommands"
|
408
|
+
argument :root_command_argument, desc: "Root command argument", required: true
|
409
|
+
option :root_command_option, desc: "Root command option"
|
410
|
+
|
411
|
+
def call(**params)
|
412
|
+
puts "I'm a root-command argument:#{params[:root_command_argument]}"
|
413
|
+
puts "I'm a root-command option:#{params[:root_command_option]}"
|
414
|
+
end
|
415
|
+
end
|
416
|
+
|
417
|
+
module RootCommands
|
418
|
+
class SubCommand < Dry::CLI::Command
|
419
|
+
desc "Root command sub command"
|
420
|
+
argument :root_command_sub_command_argument, desc: "Root command sub command argument", required: true
|
421
|
+
option :root_command_sub_command_option, desc: "Root command sub command option"
|
422
|
+
|
423
|
+
def call(**params)
|
424
|
+
puts "I'm a root-command sub-command argument:#{params[:root_command_sub_command_argument]}"
|
425
|
+
puts "I'm a root-command sub-command option:#{params[:root_command_sub_command_option]}"
|
426
|
+
end
|
427
|
+
end
|
428
|
+
|
429
|
+
class SubCommand2 < Dry::CLI::Command
|
430
|
+
desc "Root command sub command"
|
431
|
+
argument :root_command_sub_command_argument, desc: "Root command sub command argument", required: true
|
432
|
+
option :root_command_sub_command_option, desc: "Root command sub command option"
|
433
|
+
|
434
|
+
def call(**params)
|
435
|
+
puts "I'm a root-command sub-command argument:#{params[:root_command_sub_command_argument]}"
|
436
|
+
puts "I'm a root-command sub-command option:#{params[:root_command_sub_command_option]}"
|
437
|
+
end
|
438
|
+
end
|
439
|
+
end
|
440
|
+
|
441
|
+
class InitializedCommand < Dry::CLI::Command
|
442
|
+
attr_reader :prop
|
443
|
+
|
444
|
+
def initialize(prop:)
|
445
|
+
@prop = prop
|
446
|
+
end
|
447
|
+
|
448
|
+
def call(**_params)
|
449
|
+
puts "The value of prop is #{prop}"
|
450
|
+
end
|
451
|
+
end
|
452
|
+
end
|
453
|
+
|
454
|
+
module Webpack
|
455
|
+
module CLI
|
456
|
+
class Generate < Dry::CLI::Command
|
457
|
+
desc "Generate webpack configuration"
|
458
|
+
|
459
|
+
option :apps, desc: "Generate webpack apps", type: :array
|
460
|
+
|
461
|
+
def call(apps: [], **)
|
462
|
+
puts "generate webpack. Apps: #{apps}"
|
463
|
+
end
|
464
|
+
end
|
465
|
+
|
466
|
+
class Hello < Dry::CLI::Command
|
467
|
+
desc "Print a greeting"
|
468
|
+
|
469
|
+
def call(*)
|
470
|
+
puts "hello from webpack"
|
471
|
+
end
|
472
|
+
end
|
473
|
+
|
474
|
+
class SubCommand < Dry::CLI::Command
|
475
|
+
desc "Override a subcommand"
|
476
|
+
|
477
|
+
def call(**)
|
478
|
+
puts "override from webpack"
|
479
|
+
end
|
480
|
+
end
|
481
|
+
|
482
|
+
class CallbacksCommand < Dry::CLI::Command
|
483
|
+
desc "Command with callbacks"
|
484
|
+
argument :dir, required: true
|
485
|
+
option :url
|
486
|
+
|
487
|
+
def call(dir:, url: nil, **)
|
488
|
+
puts "dir: #{dir}, url: #{url.inspect}"
|
489
|
+
end
|
490
|
+
end
|
491
|
+
end
|
492
|
+
end
|
493
|
+
|
494
|
+
module Callbacks
|
495
|
+
class BeforeClass
|
496
|
+
def call(args)
|
497
|
+
puts "before callback (class), #{count(args)} arg(s): #{args.inspect}"
|
498
|
+
end
|
499
|
+
|
500
|
+
private
|
501
|
+
|
502
|
+
def count(args)
|
503
|
+
args.count
|
504
|
+
end
|
505
|
+
end
|
506
|
+
|
507
|
+
class AfterClass
|
508
|
+
def call(args)
|
509
|
+
puts "after callback (class), #{count(args)} arg(s): #{args.inspect}"
|
510
|
+
end
|
511
|
+
|
512
|
+
private
|
513
|
+
|
514
|
+
def count(args)
|
515
|
+
args.count
|
516
|
+
end
|
517
|
+
end
|
518
|
+
|
519
|
+
class Before
|
520
|
+
def call(args)
|
521
|
+
puts "before callback (object), #{count(args)} arg(s): #{args.inspect}"
|
522
|
+
end
|
523
|
+
|
524
|
+
private
|
525
|
+
|
526
|
+
def count(args)
|
527
|
+
args.count
|
528
|
+
end
|
529
|
+
end
|
530
|
+
|
531
|
+
class After
|
532
|
+
def call(args)
|
533
|
+
puts "after callback (object), #{count(args)} arg(s): #{args.inspect}"
|
534
|
+
end
|
535
|
+
|
536
|
+
private
|
537
|
+
|
538
|
+
def count(args)
|
539
|
+
args.count
|
540
|
+
end
|
541
|
+
end
|
542
|
+
end
|
543
|
+
|
544
|
+
module InheritedCommands
|
545
|
+
class Base < Dry::CLI::Command
|
546
|
+
desc "Base description"
|
547
|
+
argument :app, desc: "Application name", type: :string, required: true
|
548
|
+
option :verbosity, desc: "Verbosity level", type: :string, default: "INFO"
|
549
|
+
example "Base example"
|
550
|
+
|
551
|
+
def call(app:, **options)
|
552
|
+
puts "Base - App: #{app} - Options: #{options.inspect}"
|
553
|
+
end
|
554
|
+
end
|
555
|
+
|
556
|
+
class Run < Base
|
557
|
+
desc "Run a one-off process inside your app"
|
558
|
+
argument :cmd, desc: "Command to execute", required: true
|
559
|
+
|
560
|
+
def call(app:, cmd:, **options)
|
561
|
+
puts "#{self.class} - App: #{app} - Command: #{cmd} - Options: #{options.inspect}"
|
562
|
+
end
|
563
|
+
end
|
564
|
+
|
565
|
+
class SubRun < Run
|
566
|
+
end
|
567
|
+
|
568
|
+
class Logs < Base
|
569
|
+
desc "Display recent log output"
|
570
|
+
|
571
|
+
option :num, desc: "number of lines to display"
|
572
|
+
option :tail, desc: "continually stream log", type: :boolean
|
573
|
+
|
574
|
+
example [
|
575
|
+
"APP_NAME",
|
576
|
+
"APP_NAME --num=50",
|
577
|
+
"APP_NAME --tail"
|
578
|
+
]
|
579
|
+
|
580
|
+
def call(app:, **options)
|
581
|
+
puts "Logs - App: #{app} - Options: #{options.inspect}"
|
582
|
+
end
|
583
|
+
end
|
584
|
+
|
585
|
+
class Addons < Base
|
586
|
+
desc "Lists your add-ons and attachments"
|
587
|
+
|
588
|
+
option :json, desc: "return add-ons in json format", type: :boolean, default: false
|
589
|
+
|
590
|
+
example [
|
591
|
+
"APP_NAME",
|
592
|
+
"APP_NAME --json"
|
593
|
+
]
|
594
|
+
end
|
595
|
+
end
|
596
|
+
# rubocop:enable Metrics/LineLength
|