@@ -22,22 +22,26 @@ Or install it yourself as:
22
22
23
23
## Usage
24
24
25
+ Creating programs and commands with Mercenary is easy:
26
+
25
27
``` ruby
26
28
Mercenary .program(:jekyll ) do |p |
27
29
p .version Jekyll ::VERSION
28
30
p .description ' Jekyll is a blog-aware, static site generator in Ruby'
31
+ p .syntax " jekyll <subcommand> [options]"
29
32
30
33
p .command(:new ) do |c |
31
- c.syntax " jekyll new PATH"
34
+ c.syntax " new PATH" # do not include the program name or super commands
32
35
c.description " Creates a new Jekyll site scaffold in PATH"
36
+ c.option ' blank' , ' --blank' , ' Initialize the new site without any content."
33
37
34
38
c.action do |args, options|
35
- Jekyll ::Commands ::New .process(args)
39
+ Jekyll::Commands::New.process(args, blank: options[ ' blank ' ] )
36
40
end
37
41
end
38
42
39
43
p.command(:build) do |c|
40
- c.syntax " jekyll build [options]"
44
+ c.syntax "build [options]"
41
45
c.description "Builds your Jekyll site"
42
46
43
47
c.option ' safe' , ' -- safe' , ' Run in safe mode'
@@ -49,28 +53,23 @@ Mercenary.program(:jekyll) do |p|
49
53
end
50
54
end
51
55
52
- p .command(:import ) do |c |
53
- c.syntax " jekyll import <platform> [options]"
54
- c.description " Import your old blog to Jekyll"
55
-
56
- c.action do |args , options |
57
- begin
58
- require " jekyll-import"
59
- rescue
60
- msg = " You must install the 'jekyll-import' gem before continuing.\n "
61
- msg += " * Do this by running `gem install jekyll-import`.\n "
62
- msg += " * Or if you need root privileges, run `sudo gem install jekyll-import`."
63
- abort msg
64
- end
65
-
66
- Jekyll ::Commands ::Import .process(args.first, options)
67
- end
56
+ # Bring in command bundled in external gem
57
+ begin
58
+ require "jekyll-import"
59
+ JekyllImport.init_with_program(p)
60
+ rescue LoadError
68
61
end
69
62
70
63
p.default_command(:build)
71
64
end
72
65
```
73
66
67
+ All commands have the following default options:
68
+
69
+ - `-h/--help` - show a help message
70
+ - `-v/--version` - show the program version
71
+ - `-t/--trace` - show the full backtrace when an error occurs
72
+
74
73
## Contributing
75
74
76
75
1. Fork it
0 commit comments