tcollier-commando 0.1.0 → 0.1.1
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/.gitignore +2 -0
- data/README.md +28 -6
- data/lib/commando/action/help.rb +2 -1
- data/lib/commando/config.rb +5 -5
- data/lib/commando/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b409b80542b9797e8624584c37b6850b16ae7834
|
4
|
+
data.tar.gz: 7379329a9a815040d178da7008625add71b56d97
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 876079a43c673ac8e7817ea08da0222ccda8cecca6e98cc4f5ac17655f17c2b000e0a57aa3e4add91f46890239a47c4be8eef90d2ae7111d484e1ccfae4a7bab
|
7
|
+
data.tar.gz: d1baa3112c277c030cb8d35fe80447aa7fe0d5bf3fe647288c597d541a44cbed9265ab24e3b907b44c7cda3d5eceee396260b8c057031f9671428ce550f2606e
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -2,6 +2,11 @@
|
|
2
2
|
|
3
3
|
A command line interface builder with Readline support
|
4
4
|
|
5
|
+
## Versions
|
6
|
+
|
7
|
+
* `0.1.0` - Initial release
|
8
|
+
* `0.1.1` - Alphabetize commands printed via `help`
|
9
|
+
|
5
10
|
## Installation
|
6
11
|
|
7
12
|
Add this line to your application's Gemfile:
|
@@ -34,12 +39,24 @@ end
|
|
34
39
|
|
35
40
|
### Actions
|
36
41
|
|
37
|
-
To support a new command, you must register it with
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
42
|
+
To support a new command, you must register it with
|
43
|
+
|
44
|
+
* The command the user will type (e.g. `addfriend`).
|
45
|
+
* A class/module/instance that fills the `Action` role.
|
46
|
+
* A brief description of what the command does and what arguments it takes, if any.
|
47
|
+
|
48
|
+
#### Action role
|
49
|
+
|
50
|
+
The `Action role` responds to `perform(args, output:)`, where
|
51
|
+
|
52
|
+
* `args` [`Array<String>`] - the list of the extra words that follow the command
|
53
|
+
(e.g. if the user types `addfriend mary jane`, then the args are `['mary', 'jane']`).
|
54
|
+
* `output` [`IO`] - the IO instance that any messages should be written to.
|
55
|
+
|
56
|
+
If the arguments are not formatted correctly (e.g. the user missed an argument),
|
57
|
+
then method should raise a `Commando::ValidationError` with a descriptive message.
|
58
|
+
|
59
|
+
#### Default actions
|
43
60
|
|
44
61
|
A few default actions have been registered
|
45
62
|
|
@@ -47,6 +64,11 @@ A few default actions have been registered
|
|
47
64
|
* history - Prints the history of commands entered so far
|
48
65
|
* quit - Exits the program
|
49
66
|
|
67
|
+
## Usage
|
68
|
+
|
69
|
+
Once commando is configured, simply run `Commando.start` to enter the command
|
70
|
+
line interface.
|
71
|
+
|
50
72
|
## Contributing
|
51
73
|
|
52
74
|
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/commando. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
data/lib/commando/action/help.rb
CHANGED
@@ -6,7 +6,8 @@ module Commando
|
|
6
6
|
module Help
|
7
7
|
def self.perform(args:, output: $stdout)
|
8
8
|
output.puts "Valid commands are"
|
9
|
-
Commando.config.
|
9
|
+
descriptions = Commando.config.descriptions
|
10
|
+
descriptions.sort_by { |cmd, _| cmd }.each do |command, description|
|
10
11
|
output.puts " * #{command} - #{description}"
|
11
12
|
end
|
12
13
|
end
|
data/lib/commando/config.rb
CHANGED
@@ -4,6 +4,7 @@ require_relative 'action/quit'
|
|
4
4
|
|
5
5
|
module Commando
|
6
6
|
ActionConfig = Struct.new(:action_class, :description)
|
7
|
+
private_constant :ActionConfig
|
7
8
|
|
8
9
|
# Manage the configuration for the actions available to the CLI
|
9
10
|
class Config
|
@@ -52,11 +53,10 @@ module Commando
|
|
52
53
|
mapping[command]&.action_class
|
53
54
|
end
|
54
55
|
|
55
|
-
#
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
yield command, action_config.description
|
56
|
+
# @return [Hash<String, String>] a map of commands to their descriptions
|
57
|
+
def descriptions
|
58
|
+
mapping.map.with_object({}) do |(command, action_config), hash|
|
59
|
+
hash[command] = action_config.description
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
data/lib/commando/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tcollier-commando
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tom Collier
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-04-
|
11
|
+
date: 2017-04-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|