ordu 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -0
- data/lib/ordu.rb +10 -0
- data/ordu.gemspec +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 323735146c86f754868b1bb581c06055d6788839
|
4
|
+
data.tar.gz: 8a71af7f12a2fac14f974c33c2e180bcb12e93b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 04a5ff37e41f840dcd16cde85ec911b5ad8894caf8f6ad7194a13599047fa8cf1ec21ec146051f373db884870d2e98d81a6112a16eb741286ea74fe70d23009b
|
7
|
+
data.tar.gz: 2bf31c5b992d75be1f4be7df03ea8d485b3b71566d5d208d03375c29a42f7c790e4d6cb3aaebef94856c3b20f8f2d13da353ebe34a79292db49e11dab85534f8
|
data/README.md
CHANGED
@@ -68,6 +68,9 @@ You can see it in action if you're in this project's directory, and you run
|
|
68
68
|
examples/sneezer.rb -h
|
69
69
|
examples/sneezer.rb sneeze -h
|
70
70
|
|
71
|
+
These commands print out the Ordús, and thence the options and available
|
72
|
+
commands.
|
73
|
+
|
71
74
|
## Development
|
72
75
|
|
73
76
|
After checking out the repo, run `bin/setup` to install dependencies. Then,
|
data/lib/ordu.rb
CHANGED
@@ -27,6 +27,7 @@ class Ordu < OptionParser
|
|
27
27
|
action ||= self.class.action
|
28
28
|
options.each { |o| option!(*o) }
|
29
29
|
commands.each { |c| command!(*c) }
|
30
|
+
on_tail(command_summary) if command_summary
|
30
31
|
@action = action
|
31
32
|
end
|
32
33
|
|
@@ -42,6 +43,15 @@ class Ordu < OptionParser
|
|
42
43
|
run(*args)
|
43
44
|
end
|
44
45
|
|
46
|
+
# A string which summarizes the commands - shown in the help
|
47
|
+
def command_summary
|
48
|
+
return if commands.empty?
|
49
|
+
w = commands.keys.map(&:length).max
|
50
|
+
lines = ["Available commands:"]
|
51
|
+
lines += commands.map { |k, v| " %-#{w}s %s" % [k, v.desc] }
|
52
|
+
lines.join("\n")
|
53
|
+
end
|
54
|
+
|
45
55
|
# Parses a new instance. Note that this must be the top-level, since you
|
46
56
|
# can't supply a name. This is convenient for starting the parser from
|
47
57
|
# scripts.
|
data/ordu.gemspec
CHANGED