hanami-cli 1.0.0.alpha1 → 2.0.0.alpha6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (101) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +50 -0
  3. data/.gitignore +4 -2
  4. data/.rspec +1 -0
  5. data/.rubocop.yml +28 -1
  6. data/CHANGELOG.md +32 -1
  7. data/CODE_OF_CONDUCT.md +84 -0
  8. data/Gemfile +9 -2
  9. data/LICENSE.txt +21 -0
  10. data/README.md +12 -605
  11. data/Rakefile +5 -10
  12. data/exe/hanami +10 -0
  13. data/hanami-cli.gemspec +22 -17
  14. data/lib/hanami/cli/bundler.rb +73 -0
  15. data/lib/hanami/cli/command.rb +14 -386
  16. data/lib/hanami/cli/command_line.rb +17 -0
  17. data/lib/hanami/cli/commands/application.rb +63 -0
  18. data/lib/hanami/cli/commands/db/utils/database.rb +122 -0
  19. data/lib/hanami/cli/commands/db/utils/database_config.rb +48 -0
  20. data/lib/hanami/cli/commands/db/utils/mysql.rb +27 -0
  21. data/lib/hanami/cli/commands/db/utils/postgres.rb +49 -0
  22. data/lib/hanami/cli/commands/db/utils/sqlite.rb +37 -0
  23. data/lib/hanami/cli/commands/gem/new.rb +77 -0
  24. data/lib/hanami/cli/commands/gem/version.rb +18 -0
  25. data/lib/hanami/cli/commands/gem.rb +21 -0
  26. data/lib/hanami/cli/commands/monolith/console.rb +49 -0
  27. data/lib/hanami/cli/commands/monolith/db/create.rb +25 -0
  28. data/lib/hanami/cli/commands/monolith/db/create_migration.rb +29 -0
  29. data/lib/hanami/cli/commands/monolith/db/drop.rb +25 -0
  30. data/lib/hanami/cli/commands/monolith/db/migrate.rb +40 -0
  31. data/lib/hanami/cli/commands/monolith/db/reset.rb +26 -0
  32. data/lib/hanami/cli/commands/monolith/db/rollback.rb +55 -0
  33. data/lib/hanami/cli/commands/monolith/db/sample_data.rb +40 -0
  34. data/lib/hanami/cli/commands/monolith/db/seed.rb +40 -0
  35. data/lib/hanami/cli/commands/monolith/db/setup.rb +24 -0
  36. data/lib/hanami/cli/commands/monolith/db/structure/dump.rb +25 -0
  37. data/lib/hanami/cli/commands/monolith/db/version.rb +26 -0
  38. data/lib/hanami/cli/commands/monolith/generate/action.rb +62 -0
  39. data/lib/hanami/cli/commands/monolith/generate/slice.rb +62 -0
  40. data/lib/hanami/cli/commands/monolith/generate.rb +14 -0
  41. data/lib/hanami/cli/commands/monolith/install.rb +16 -0
  42. data/lib/hanami/cli/commands/monolith/version.rb +18 -0
  43. data/lib/hanami/cli/commands/monolith.rb +55 -0
  44. data/lib/hanami/cli/commands.rb +26 -0
  45. data/lib/hanami/cli/error.rb +8 -0
  46. data/lib/hanami/cli/generators/context.rb +38 -0
  47. data/lib/hanami/cli/generators/gem/application/monolith/action.erb +21 -0
  48. data/lib/hanami/cli/generators/gem/application/monolith/application.erb +8 -0
  49. data/lib/hanami/cli/generators/gem/application/monolith/config_ru.erb +5 -0
  50. data/lib/hanami/cli/generators/gem/application/monolith/entities.erb +9 -0
  51. data/lib/hanami/cli/generators/gem/application/monolith/env.erb +0 -0
  52. data/lib/hanami/cli/generators/gem/application/monolith/functions.erb +13 -0
  53. data/lib/hanami/cli/generators/gem/application/monolith/gemfile.erb +19 -0
  54. data/lib/hanami/cli/generators/gem/application/monolith/keep.erb +0 -0
  55. data/lib/hanami/cli/generators/gem/application/monolith/operation.erb +18 -0
  56. data/lib/hanami/cli/generators/gem/application/monolith/rakefile.erb +3 -0
  57. data/lib/hanami/cli/generators/gem/application/monolith/readme.erb +1 -0
  58. data/lib/hanami/cli/generators/gem/application/monolith/repository.erb +13 -0
  59. data/lib/hanami/cli/generators/gem/application/monolith/routes.erb +4 -0
  60. data/lib/hanami/cli/generators/gem/application/monolith/settings.erb +6 -0
  61. data/lib/hanami/cli/generators/gem/application/monolith/types.erb +10 -0
  62. data/lib/hanami/cli/generators/gem/application/monolith/validation_contract.erb +14 -0
  63. data/lib/hanami/cli/generators/gem/application/monolith/view_context.erb +15 -0
  64. data/lib/hanami/cli/generators/gem/application/monolith.rb +83 -0
  65. data/lib/hanami/cli/generators/gem/application.rb +21 -0
  66. data/lib/hanami/cli/generators/monolith/action/action.erb +13 -0
  67. data/lib/hanami/cli/generators/monolith/action/template.erb +0 -0
  68. data/lib/hanami/cli/generators/monolith/action/template.html.erb +2 -0
  69. data/lib/hanami/cli/generators/monolith/action/view.erb +13 -0
  70. data/lib/hanami/cli/generators/monolith/action.rb +123 -0
  71. data/lib/hanami/cli/generators/monolith/action_context.rb +76 -0
  72. data/lib/hanami/cli/generators/monolith/slice/action.erb +9 -0
  73. data/lib/hanami/cli/generators/monolith/slice/entities.erb +9 -0
  74. data/lib/hanami/cli/generators/monolith/slice/keep.erb +0 -0
  75. data/lib/hanami/cli/generators/monolith/slice/repository.erb +10 -0
  76. data/lib/hanami/cli/generators/monolith/slice/routes.erb +2 -0
  77. data/lib/hanami/cli/generators/monolith/slice/view.erb +9 -0
  78. data/lib/hanami/cli/generators/monolith/slice.rb +56 -0
  79. data/lib/hanami/cli/generators/monolith/slice_context.rb +33 -0
  80. data/lib/hanami/cli/repl/core.rb +55 -0
  81. data/lib/hanami/cli/repl/irb.rb +38 -0
  82. data/lib/hanami/cli/repl/pry.rb +29 -0
  83. data/lib/hanami/cli/system_call.rb +51 -0
  84. data/lib/hanami/cli/url.rb +34 -0
  85. data/lib/hanami/cli/version.rb +2 -3
  86. data/lib/hanami/cli.rb +9 -122
  87. data/lib/hanami/console/context.rb +53 -0
  88. data/lib/hanami/console/plugins/slice_readers.rb +24 -0
  89. data/lib/hanami/rake_tasks.rb +52 -0
  90. metadata +135 -43
  91. data/.circleci/config.yml +0 -63
  92. data/.travis.yml +0 -22
  93. data/lib/hanami/cli/banner.rb +0 -129
  94. data/lib/hanami/cli/command_registry.rb +0 -215
  95. data/lib/hanami/cli/errors.rb +0 -46
  96. data/lib/hanami/cli/option.rb +0 -134
  97. data/lib/hanami/cli/parser.rb +0 -144
  98. data/lib/hanami/cli/program_name.rb +0 -21
  99. data/lib/hanami/cli/registry.rb +0 -330
  100. data/lib/hanami/cli/usage.rb +0 -91
  101. data/script/ci +0 -61
data/README.md CHANGED
@@ -1,30 +1,6 @@
1
1
  # Hanami::CLI
2
2
 
3
- General purpose Command Line Interface (CLI) framework for Ruby.
4
-
5
- :warning: **This is a general framework for Ruby (aka `thor` gem replacement), NOT the implementation of the `hanami` CLI commands** :warning:
6
-
7
- ## Status
8
-
9
- [![Gem Version](https://badge.fury.io/rb/hanami-cli.svg)](https://badge.fury.io/rb/hanami-cli)
10
- [![TravisCI](https://travis-ci.org/hanami/cli.svg?branch=master)](https://travis-ci.org/hanami/cli)
11
- [![CircleCI](https://circleci.com/gh/hanami/cli/tree/master.svg?style=svg)](https://circleci.com/gh/hanami/cli/tree/master)
12
- [![Test Coverage](https://codecov.io/gh/hanami/cli/branch/master/graph/badge.svg)](https://codecov.io/gh/hanami/cli)
13
- [![Depfu](https://badges.depfu.com/badges/2c1bc076f16c6b5508334c44b5800362/overview.svg)](https://depfu.com/github/hanami/cli?project=Bundler)
14
- [![Inline Docs](http://inch-ci.org/github/hanami/cli.svg)](http://inch-ci.org/github/hanami/cli)
15
-
16
- ## Contact
17
-
18
- * Home page: http://hanamirb.org
19
- * Mailing List: http://hanamirb.org/mailing-list
20
- * API Doc: http://rdoc.info/gems/hanami-cli
21
- * Bugs/Issues: https://github.com/hanami/cli/issues
22
- * Support: http://stackoverflow.com/questions/tagged/hanami
23
- * Chat: http://chat.hanamirb.org
24
-
25
- ## Rubies
26
-
27
- __Hanami::CLI__ supports Ruby (MRI) 2.5+
3
+ [Hanami](http://hanamirb.org) command line
28
4
 
29
5
  ## Installation
30
6
 
@@ -36,269 +12,7 @@ gem 'hanami-cli'
36
12
 
37
13
  And then execute:
38
14
 
39
- $ bundle
40
-
41
- Or install it yourself as:
42
-
43
- $ gem install hanami-cli
44
-
45
- <!-- Tocer[start]: Auto-generated, don't remove. -->
46
-
47
- ## Table of Contents
48
-
49
- - [Features](#features)
50
- - [Registration](#registration)
51
- - [Commands as objects](#commands-as-objects)
52
- - [Subcommands](#subcommands)
53
- - [Arguments](#arguments)
54
- - [Option](#option)
55
- - [Variadic arguments](#variadic-arguments)
56
- - [Installation](#installation)
57
- - [Usage](#usage)
58
- - [Available commands](#available-commands)
59
- - [Help](#help)
60
- - [Optional arguments](#optional-arguments)
61
- - [Required arguments](#required-arguments)
62
- - [Options](#options)
63
- - [Boolean options](#boolean-options)
64
- - [Array options](#array-options)
65
- - [Subcommands](#subcommands-1)
66
- - [Aliases](#aliases)
67
- - [Subcommand aliases](#subcommand-aliases)
68
- - [Callbacks](#callbacks)
69
- - [Development](#development)
70
- - [Contributing](#contributing)
71
- - [Alternatives](#alternatives)
72
- - [Copyright](#copyright)
73
-
74
- <!-- Tocer[finish]: Auto-generated, don't remove. -->
75
-
76
- ## Features
77
-
78
- ### Registration
79
-
80
- For a given _command name_, you can register a corresponding _command object_ (aka command).
81
-
82
- Example: for `foo hi` _command name_ there is the corresponding `Foo::CLI::Hello` _command object_.
83
-
84
- ```ruby
85
- #!/usr/bin/env ruby
86
- require "bundler/setup"
87
- require "hanami/cli"
88
-
89
- module Foo
90
- module CLI
91
- module Commands
92
- extend Hanami::CLI::Registry
93
-
94
- class Hello < Hanami::CLI::Command
95
- def call(*)
96
- end
97
- end
98
- end
99
- end
100
- end
101
-
102
- class Version < Hanami::CLI::Command
103
- def call(*)
104
- end
105
- end
106
-
107
- Foo::CLI::Commands.register "hi", Foo::CLI::Commands::Hello
108
- Foo::CLI::Commands.register "v", Version
109
-
110
- Hanami::CLI.new(Foo::CLI::Commands).call
111
- ```
112
-
113
- **Please note:** there is NOT a convention between the _command name_ and the _command object_ class.
114
- The manual _registration_ assigns a _command object_ to a _command name_.
115
-
116
- ### Commands as objects
117
-
118
- A command is a subclass of `Hanami::CLI::Command` and it MUST respond to `#call(*)`.
119
-
120
- ### Subcommands
121
-
122
- There is nothing special in subcommands: they are just _command objects_ registered under a **nested** _command name_.
123
-
124
- ```ruby
125
- #!/usr/bin/env ruby
126
- require "bundler/setup"
127
- require "hanami/cli"
128
-
129
- module Foo
130
- module CLI
131
- module Commands
132
- extend Hanami::CLI::Registry
133
-
134
- module Generate
135
- class Configuration < Hanami::CLI::Command
136
- def call(*)
137
- end
138
- end
139
- end
140
- end
141
- end
142
- end
143
-
144
- Foo::CLI::Commands.register "generate configuration", Foo::CLI::Commands::Generate::Configuration
145
-
146
- Hanami::CLI.new(Foo::CLI::Commands).call
147
- ```
148
-
149
- ### Arguments
150
-
151
- An argument is a token passed after the _command name_.
152
- For instance, given the `foo greet` command, when an user types `foo greet Luca`, then `Luca` is considered an argument.
153
- A command can accept none or many arguments.
154
- An argument can be declared as _required_.
155
-
156
- ```ruby
157
- #!/usr/bin/env ruby
158
- require "bundler/setup"
159
- require "hanami/cli"
160
-
161
- module Foo
162
- module CLI
163
- module Commands
164
- extend Hanami::CLI::Registry
165
-
166
- class Greet < Hanami::CLI::Command
167
- argument :name, required: true, desc: "The name of the person to greet"
168
- argument :age, desc: "The age of the person to greet"
169
-
170
- def call(name:, age: nil, **)
171
- result = "Hello, #{name}."
172
- result = "#{result} You are #{age} years old." unless age.nil?
173
-
174
- puts result
175
- end
176
- end
177
-
178
- register "greet", Greet
179
- end
180
- end
181
- end
182
-
183
- Hanami::CLI.new(Foo::CLI::Commands).call
184
- ```
185
-
186
- ```shell
187
- % foo greet Luca
188
- Hello, Luca.
189
- ```
190
-
191
- ```shell
192
- % foo greet Luca 35
193
- Hello, Luca. You are 35 years old.
194
- ```
195
-
196
- ```shell
197
- % foo greet
198
- ERROR: "foo greet" was called with no arguments
199
- Usage: "foo greet NAME"
200
- ```
201
-
202
- ### Option
203
-
204
- An option is a named argument that is passed after the _command name_ **and** the arguments.
205
-
206
- For instance, given the `foo request` command, when an user types `foo request --mode=http2`, then `--mode=http2` is considered an option.
207
- A command can accept none or many options.
208
-
209
- ```ruby
210
- #!/usr/bin/env ruby
211
- require "bundler/setup"
212
- require "hanami/cli"
213
-
214
- module Foo
215
- module CLI
216
- module Commands
217
- extend Hanami::CLI::Registry
218
-
219
- class Request < Hanami::CLI::Command
220
- option :mode, default: "http", values: %w[http http2], desc: "The request mode"
221
-
222
- def call(**options)
223
- puts "Performing a request (mode: #{options.fetch(:mode)})"
224
- end
225
- end
226
-
227
- register "request", Request
228
- end
229
- end
230
- end
231
-
232
- Hanami::CLI.new(Foo::CLI::Commands).call
233
- ```
234
-
235
- ```shell
236
- % foo request
237
- Performing a request (mode: http)
238
- ```
239
-
240
- ```shell
241
- % foo request --mode=http2
242
- Performing a request (mode: http2)
243
- ```
244
-
245
- ```shell
246
- % foo request --mode=unknown
247
- Error: "request" was called with arguments "--mode=unknown"
248
- ```
249
-
250
- ### Variadic arguments
251
-
252
- Sometimes we need extra arguments because those will be forwarded to a sub-command like `ssh`, `docker` or `cat`.
253
-
254
- By using `--` (double dash, aka hypen), the user indicates the end of the arguments and options belonging to the main command, and the beginning of the variadic arguments that can be forwarded to the sub-command.
255
- These extra arguments are included as `:args` in the keyword arguments available for each command.
256
-
257
- ```ruby
258
- #!/usr/bin/env ruby
259
- require "bundler/setup"
260
- require "hanami/cli"
261
-
262
- module Foo
263
- module CLI
264
- module Commands
265
- extend Hanami::CLI::Registry
266
-
267
- class Runner < Hanami::CLI::Command
268
- argument :image, required: true, desc: "Docker image"
269
-
270
- def call(image:, args: [], **)
271
- puts `docker run -it --rm #{image} #{args.join(" ")}`
272
- end
273
- end
274
-
275
- register "run", Runner
276
- end
277
- end
278
- end
279
-
280
- Hanami::CLI.new(Foo::CLI::Commands).call
281
- ```
282
-
283
- ```shell
284
- % foo run ruby:latest -- ruby -v
285
- ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux]
286
- ```
287
-
288
- The user separates via `--` the arguments for `foo` and the command has to be run by the Docker container.
289
- In this specific case, `ruby:latest` corresponds to the `image` mandatory argument for `foo`, whereas `ruby -v` is the variadic argument that is passed to Docker via `args`.
290
-
291
- ## Installation
292
-
293
- Add this line to your application's Gemfile:
294
-
295
- ```ruby
296
- gem "hanami-cli"
297
- ```
298
-
299
- And then execute:
300
-
301
- $ bundle
15
+ $ bundle install
302
16
 
303
17
  Or install it yourself as:
304
18
 
@@ -306,331 +20,24 @@ Or install it yourself as:
306
20
 
307
21
  ## Usage
308
22
 
309
- Imagine to build a CLI executable `foo` for your Ruby project.
310
-
311
- ```ruby
312
- #!/usr/bin/env ruby
313
- require "bundler/setup"
314
- require "hanami/cli"
315
-
316
- module Foo
317
- module CLI
318
- module Commands
319
- extend Hanami::CLI::Registry
320
-
321
- class Version < Hanami::CLI::Command
322
- desc "Print version"
323
-
324
- def call(*)
325
- puts "1.0.0"
326
- end
327
- end
328
-
329
- class Echo < Hanami::CLI::Command
330
- desc "Print input"
331
-
332
- argument :input, desc: "Input to print"
333
-
334
- example [
335
- " # Prints 'wuh?'",
336
- "hello, folks # Prints 'hello, folks'"
337
- ]
338
-
339
- def call(input: nil, **)
340
- if input.nil?
341
- puts "wuh?"
342
- else
343
- puts input
344
- end
345
- end
346
- end
347
-
348
- class Start < Hanami::CLI::Command
349
- desc "Start Foo machinery"
350
-
351
- argument :root, required: true, desc: "Root directory"
352
-
353
- example [
354
- "path/to/root # Start Foo at root directory"
355
- ]
356
-
357
- def call(root:, **)
358
- puts "started - root: #{root}"
359
- end
360
- end
361
-
362
- class Stop < Hanami::CLI::Command
363
- desc "Stop Foo machinery"
364
-
365
- option :graceful, type: :boolean, default: true, desc: "Graceful stop"
366
-
367
- def call(**options)
368
- puts "stopped - graceful: #{options.fetch(:graceful)}"
369
- end
370
- end
371
-
372
- class Exec < Hanami::CLI::Command
373
- desc "Execute a task"
374
-
375
- argument :task, type: :string, required: true, desc: "Task to be executed"
376
- argument :dirs, type: :array, required: false, desc: "Optional directories"
377
-
378
- def call(task:, dirs: [], **)
379
- puts "exec - task: #{task}, dirs: #{dirs.inspect}"
380
- end
381
- end
382
-
383
- module Generate
384
- class Configuration < Hanami::CLI::Command
385
- desc "Generate configuration"
386
-
387
- option :apps, type: :array, default: [], desc: "Generate configuration for specific apps"
388
-
389
- def call(apps:, **)
390
- puts "generated configuration for apps: #{apps.inspect}"
391
- end
392
- end
393
-
394
- class Test < Hanami::CLI::Command
395
- desc "Generate tests"
396
-
397
- option :framework, default: "minitest", values: %w[minitest rspec]
398
-
399
- def call(framework:, **)
400
- puts "generated tests - framework: #{framework}"
401
- end
402
- end
403
- end
404
-
405
- register "version", Version, aliases: ["v", "-v", "--version"]
406
- register "echo", Echo
407
- register "start", Start
408
- register "stop", Stop
409
- register "exec", Exec
410
-
411
- register "generate", aliases: ["g"] do |prefix|
412
- prefix.register "config", Generate::Configuration
413
- prefix.register "test", Generate::Test
414
- end
415
- end
416
- end
417
- end
418
-
419
- Hanami::CLI.new(Foo::CLI::Commands).call
420
- ```
421
-
422
- Let's have a look at the command line usage.
423
-
424
- ### Available commands
425
-
426
- ```shell
427
- % foo
428
- Commands:
429
- foo echo [INPUT] # Print input
430
- foo exec TASK [DIRS] # Execute a task
431
- foo generate [SUBCOMMAND]
432
- foo start ROOT # Start Foo machinery
433
- foo stop # Stop Foo machinery
434
- foo version # Print version
435
- ```
436
-
437
- ### Help
438
-
439
- ```shell
440
- % foo echo --help
441
- Command:
442
- foo echo
443
-
444
- Usage:
445
- foo echo [INPUT]
446
-
447
- Description:
448
- Print input
449
-
450
- Arguments:
451
- INPUT # Input to print
452
-
453
- Options:
454
- --help, -h # Print this help
455
-
456
- Examples:
457
- foo echo # Prints 'wuh?'
458
- foo echo hello, folks # Prints 'hello, folks'
459
- ```
460
-
461
- ### Optional arguments
462
-
463
- ```shell
464
- % foo echo
465
- wuh?
466
-
467
- % foo echo hello
468
- hello
469
- ```
470
-
471
- ### Required arguments
472
-
473
- ```shell
474
- % foo start .
475
- started - root: .
476
- ```
477
-
478
- ```shell
479
- % foo start
480
- ERROR: "foo start" was called with no arguments
481
- Usage: "foo start ROOT"
482
- ```
483
-
484
- ### Array arguments
485
-
486
- Captures all the remaining arguments in a single array.
487
- Please note that `array` argument must be used as last argument as it works as a _"catch-all"_.
488
-
489
- ```shell
490
- % foo exec test
491
- exec - task: test, dirs: []
492
- ```
493
-
494
- ```shell
495
- % foo exec test spec/bookshelf/entities spec/bookshelf/repositories
496
- exec - task: test, dirs: ["spec/bookshelf/entities", "spec/bookshelf/repositories"]
497
- ```
498
-
499
- ### Options
500
-
501
- ```shell
502
- % foo generate test
503
- generated tests - framework: minitest
504
- ```
505
-
506
- ```shell
507
- % foo generate test --framework=rspec
508
- generated tests - framework: rspec
509
- ```
510
-
511
- ```shell
512
- % foo generate test --framework=unknown
513
- Error: "test" was called with arguments "--framework=unknown"
514
- ```
515
-
516
- ### Boolean options
517
-
518
- ```shell
519
- % foo stop
520
- stopped - graceful: true
521
- ```
522
-
523
- ```shell
524
- % foo stop --no-graceful
525
- stopped - graceful: false
526
- ```
527
-
528
- ### Array options
529
-
530
- ```shell
531
- % foo generate config --apps=web,api
532
- generated configuration for apps: ["web", "api"]
533
- ```
534
-
535
- ### Subcommands
536
-
537
- ```shell
538
- % foo generate
539
- Commands:
540
- foo generate config # Generate configuration
541
- foo generate test # Generate tests
542
- ```
543
-
544
- ### Aliases
545
-
546
- ```shell
547
- % foo version
548
- 1.0.0
549
- ```
550
-
551
- ```shell
552
- % foo v
553
- 1.0.0
554
- ```
555
-
556
- ```shell
557
- % foo -v
558
- 1.0.0
559
- ```
560
-
561
- ```shell
562
- % foo --version
563
- 1.0.0
564
- ```
565
-
566
- ### Subcommand aliases
567
-
568
- ```shell
569
- % foo g config
570
- generated configuration for apps: []
571
- ```
572
-
573
- ### Callbacks
574
-
575
- Third party gems can register _before_ and _after_ callbacks to enhance a command.
576
-
577
- From the `foo` gem we have a command `hello`.
578
-
579
- ```ruby
580
- #!/usr/bin/env ruby
581
- require "hanami/cli"
582
-
583
- module Foo
584
- module CLI
585
- module Commands
586
- extend Hanami::CLI::Registry
587
-
588
- class Hello < Hanami::CLI::Command
589
- argument :name, required: true
590
-
591
- def call(name:, **)
592
- puts "hello #{name}"
593
- end
594
- end
595
- end
596
- end
597
- end
598
-
599
- Foo::CLI::Commands.register "hello", Foo::CLI::Commands::Hello
600
-
601
- cli = Hanami::CLI.new(Foo::CLI::Commands)
602
- cli.call
603
- ```
604
-
605
- The `foo-bar` gem enhances `hello` command with callbacks:
606
-
607
- ```
608
- Foo::CLI::Commands.before("hello") { |args| puts "debug: #{args.inspect}" } # syntax 1
609
- Foo::CLI::Commands.after "hello", &->(args) { puts "bye, #{args.fetch(:name)}" } # syntax 2
610
- ```
611
-
612
- ```shell
613
- % foo hello Anton
614
- debug: {:name=>"Anton"}
615
- hello Anton
616
- bye, Anton
617
- ```
618
-
619
23
  ## Development
620
24
 
621
- After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
25
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
622
26
 
623
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
27
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
624
28
 
625
29
  ## Contributing
626
30
 
627
- Bug reports and pull requests are welcome on GitHub at https://github.com/hanami/cli.
31
+ Bug reports and pull requests are welcome on GitHub at https://github.com/hanami/cli. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/hanami/cli/blob/main/CODE_OF_CONDUCT.md).
32
+
33
+ ## License
34
+
35
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
628
36
 
629
- ## Alternatives
37
+ ## Code of Conduct
630
38
 
631
- * [thor](http://whatisthor.com/)
632
- * [clamp](https://github.com/mdub/clamp)
39
+ Everyone interacting in the `Hanami::CLI` project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/hanami/cli/blob/main/CODE_OF_CONDUCT.md).
633
40
 
634
41
  ## Copyright
635
42
 
636
- Copyright © 2017-2019 Luca Guidi – Released under MIT License
43
+ Copyright © 2014-2022 Hanami Team – Released under MIT License
data/Rakefile CHANGED
@@ -1,17 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "rake"
4
3
  require "bundler/gem_tasks"
5
4
  require "rspec/core/rake_task"
6
- require "hanami/devtools/rake_tasks"
7
5
 
8
- namespace :spec do
9
- RSpec::Core::RakeTask.new(:unit) do |task|
10
- file_list = FileList["spec/**/*_spec.rb"]
11
- file_list = file_list.exclude("spec/{integration,isolation}/**/*_spec.rb")
6
+ RSpec::Core::RakeTask.new(:spec)
12
7
 
13
- task.pattern = file_list
14
- end
15
- end
8
+ require "rubocop/rake_task"
16
9
 
17
- task default: "spec:unit"
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
data/exe/hanami ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "hanami/cli"
6
+
7
+ cli = Dry::CLI.new(Hanami::CLI)
8
+ Hanami::CLI::Bundler.require(:cli)
9
+
10
+ cli.call