escort 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. checksums.yaml +15 -0
  2. data/.gitignore +1 -0
  3. data/.irbrc +1 -0
  4. data/.rspec +3 -0
  5. data/.rvmrc +22 -0
  6. data/README.md +31 -56
  7. data/TODO.md +152 -0
  8. data/escort.gemspec +6 -2
  9. data/examples/1_1_basic.rb +15 -0
  10. data/examples/1_2_basic_requires_arguments.rb +15 -0
  11. data/examples/2_2_command.rb +18 -0
  12. data/examples/2_2_command_requires_arguments.rb +20 -0
  13. data/examples/2_3_nested_commands.rb +26 -0
  14. data/examples/3_validations.rb +31 -0
  15. data/examples/4_1_config_file.rb +42 -0
  16. data/examples/argument_handling/basic.rb +12 -0
  17. data/examples/argument_handling/basic_command.rb +18 -0
  18. data/examples/argument_handling/no_arguments.rb +14 -0
  19. data/examples/argument_handling/no_arguments_command.rb +20 -0
  20. data/examples/basic/app.rb +16 -0
  21. data/examples/command_aliases/app.rb +31 -0
  22. data/examples/config_file/.apprc2 +16 -0
  23. data/examples/config_file/app.rb +78 -0
  24. data/examples/config_file/sub_commands.rb +35 -0
  25. data/examples/default_command/app.rb +20 -0
  26. data/examples/sub_commands/app.rb +18 -0
  27. data/examples/validation_basic/app.rb +31 -0
  28. data/lib/escort.rb +51 -4
  29. data/lib/escort/action_command/base.rb +79 -0
  30. data/lib/escort/action_command/escort_utility_command.rb +53 -0
  31. data/lib/escort/app.rb +89 -36
  32. data/lib/escort/arguments.rb +20 -0
  33. data/lib/escort/auto_options.rb +71 -0
  34. data/lib/escort/error/error.rb +50 -0
  35. data/lib/escort/formatter/borderless_table.rb +102 -0
  36. data/lib/escort/formatter/common.rb +58 -0
  37. data/lib/escort/formatter/default_help_formatter.rb +106 -0
  38. data/lib/escort/formatter/options.rb +13 -0
  39. data/lib/escort/formatter/string_splitter.rb +30 -0
  40. data/lib/escort/formatter/terminal.rb +22 -0
  41. data/lib/escort/formatter/terminal_formatter.rb +52 -0
  42. data/lib/escort/global_pre_parser.rb +43 -0
  43. data/lib/escort/logger.rb +75 -0
  44. data/lib/escort/option_parser.rb +145 -0
  45. data/lib/escort/setup/configuration/generator.rb +75 -0
  46. data/lib/escort/setup/configuration/instance.rb +33 -0
  47. data/lib/escort/setup/configuration/loader.rb +37 -0
  48. data/lib/escort/setup/configuration/locator/base.rb +19 -0
  49. data/lib/escort/setup/configuration/locator/descending_to_home.rb +23 -0
  50. data/lib/escort/setup/configuration/merge_tool.rb +38 -0
  51. data/lib/escort/setup/configuration/reader.rb +36 -0
  52. data/lib/escort/setup/configuration/writer.rb +44 -0
  53. data/lib/escort/setup/dsl/action.rb +17 -0
  54. data/lib/escort/setup/dsl/command.rb +74 -0
  55. data/lib/escort/setup/dsl/config_file.rb +13 -0
  56. data/lib/escort/setup/dsl/global.rb +84 -0
  57. data/lib/escort/setup/dsl/options.rb +25 -0
  58. data/lib/escort/setup/dsl/validations.rb +25 -0
  59. data/lib/escort/setup_accessor.rb +194 -0
  60. data/lib/escort/trollop.rb +15 -4
  61. data/lib/escort/utils.rb +21 -0
  62. data/lib/escort/validator.rb +42 -0
  63. data/lib/escort/version.rb +1 -1
  64. data/spec/helpers/execute_action_matcher.rb +21 -0
  65. data/spec/helpers/exit_with_code_matcher.rb +21 -0
  66. data/spec/helpers/give_option_to_action_with_value_matcher.rb +22 -0
  67. data/spec/integration/basic_options_spec.rb +53 -0
  68. data/spec/integration/basic_spec.rb +24 -0
  69. data/spec/lib/escort/formatter/string_splitter_spec.rb +38 -0
  70. data/spec/lib/escort/setup_accessor_spec.rb +42 -0
  71. data/spec/lib/escort/utils_spec.rb +30 -0
  72. data/spec/spec_helper.rb +22 -0
  73. metadata +128 -16
  74. data/lib/escort/command.rb +0 -23
  75. data/lib/escort/dsl.rb +0 -20
  76. data/lib/escort/global_dsl.rb +0 -11
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ NWYwMTA5MzIxMTE3MjU2YzJhNmE0MTA5NzViNTQwZWMyNmU0YzM5Nw==
5
+ data.tar.gz: !binary |-
6
+ ZTgyNDA0NDU4OTllYTk2NGNkYTJmNGIzODk2NDQ4ZjVhOGVmZjllMQ==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ ZTU3Y2FkZWE2YjVjMTVjMDE4ZDI0OTA2YTRhZmFhMzdhN2Q4YzhhNTRkNDlh
10
+ ZDdlODcyZjUzOTEzNzliM2QzMmEyOGE2OTEzYjJjZmViMGNjNjA0MzBjMDBh
11
+ ODQ0MzA0NTU2ZGViMWY2ZWNkZWIyMWZiN2U0Y2ViY2IwNjc1MDg=
12
+ data.tar.gz: !binary |-
13
+ NDIxMjk4N2M4ZTZjMzBmNjFmOWVmYzQxMzI4Zjk5OTRlNjU1NTA0OTc2MzFj
14
+ MjMxOWZhNTliYmJjNmMzYzI2NDQ0MDExMDc5ZDdkNDA4NGU1YmUwOWQxNzI0
15
+ Y2NmMGEwYmJjNjAwYmU2MDFlNmY5OTU2ZTJkYTIxZGFlMWFiYTE=
data/.gitignore CHANGED
@@ -15,3 +15,4 @@ spec/reports
15
15
  test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
+ tags
data/.irbrc ADDED
@@ -0,0 +1 @@
1
+ require './lib/escort'
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --color
2
+ --format doc
3
+ --require spec_helper
data/.rvmrc ADDED
@@ -0,0 +1,22 @@
1
+ #!/usr/bin/env bash
2
+
3
+ failed=1
4
+ gemset=escort
5
+ rubies="ruby-1.9.3-p362 ruby-1.9.3-p194 ruby-1.9.2-p290 "
6
+
7
+ for ruby in $rubies; do
8
+ rvm use $ruby@$gemset --create 1>/dev/null 2>&1
9
+ if [ $? == 0 ]; then
10
+ echo
11
+ echo ">>" rvm is using $ruby@$gemset
12
+ echo
13
+ failed=0
14
+ break
15
+ fi
16
+ done
17
+
18
+ if [ $failed == 1 ]; then
19
+ echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
20
+ echo cannot find a ruby runtime in the set: $rubies, please install one
21
+ echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
22
+ fi
data/README.md CHANGED
@@ -1,16 +1,20 @@
1
1
  # Escort
2
2
 
3
- Basically we take the excellent Trollop command line options parser and dress it up a little with some DSL to make writing CLI apps a bit nicer, but still retain the full power of the awesome Trollop.
3
+ Writing even complex command-line apps should be quick, easy and fun. Escort takes the excellent [Trollop](http://trollop.rubyforge.org/) option parser and adds a whole bunch of awesome features to produce a library you will always want to turn to when a 'quick script' is in order.
4
4
 
5
5
  ## Why Write Another CLI Tool
6
6
 
7
- A lot of the existing CLI making libraries delegate to OptionParser for actually parsing the option string, while OptionParser is nice it doesn't allow things like specifying the same option multiple times (e.g. like CURL -H parameter) which I like and use quite often. Trollop handles this case nicely.
7
+ A lot of the existing CLI making libraries delegate to OptionParser for actually parsing the option string, while OptionParser is nice it doesn't allow things like specifying the same option multiple times (e.g. like CURL -H parameter) which I like and use quite often. Trollop handles this case nicely, so a Trollop-based CLI tool is slightly superior.
8
8
 
9
- Also a lot of the other CLI libraries in an attempt to be extra terse and DRY make their syntax a little obtuse, Trollop on the other hand, is not overly DRY, the syntax is simple and easy to understand, it just needed a little DSL to make a command line app built with it nice looking.
9
+ Also a lot of the other CLI libraries in an attempt to be extra terse and DRY make their syntax a little obtuse. Escort tries to create a DSL that strikes a balance between being terse and being easy to understand.
10
10
 
11
- Also I find that I end up with a similar structure for the CLI apps that I write and I want to capture that as a bit of a convention. An app doesn't stop at the option parsing, how do you actually structure the code that executes the work.
11
+ I find that I end up with a similar structure for the CLI apps that I write and I want to capture that as a bit of a convention. An app doesn't stop at the option parsing, how do you actually structure the code that executes the work?
12
12
 
13
- There is a bunch of other minor reasons, so there you have it.
13
+ In general, some liraries give you great option parsing, but no infinitely nesting sub command, others have sub commands, but the option parsing is inferior. I want everything out of my CLI library, without having to dig through feature lists trying to figure out what will give me the biggest bang for my buck.
14
+
15
+ ## Features
16
+
17
+ TODO
14
18
 
15
19
  ## Installation
16
20
 
@@ -28,58 +32,48 @@ Or install it yourself as:
28
32
 
29
33
  ## Usage
30
34
 
31
- Really easy, here is an example:
35
+ Let's say you want to do a basic app. As long as `escort` is installed as a gem, you might do something like this:
32
36
 
33
37
  ```ruby
34
38
  #!/usr/bin/env ruby
39
+
35
40
  require 'escort'
36
41
 
37
42
  Escort::App.create do |app|
38
- app.options do
39
- banner "my script banner"
40
- opt :global_option, "Global option", :short => '-g', :long => '--global', :type => :string, :default => "global"
41
- end
42
-
43
- app.command :my_command do |command|
44
- command.options do
45
- banner "Sub command"
46
- opt :do_stuff, "Do stuff", :short => :none, :long => '--do-stuff', :type => :boolean, :default => true
47
- end
43
+ app.version "0.2.5"
48
44
 
49
- command.action do |global_options, command_options, arguments|
50
- #actually do the work for this command here
51
- end
45
+ app.options do |opts|
46
+ opts.opt :global_option, "Global option", :short => '-g', :long => '--global', :type => :string, :default => "global"
47
+ opts.opt :multi_option, "Option that can be specified multiple times alksjdfh lakjdfh adf alksdfh alkdfjh alsdfjhaskdjfh alsdkfjh alksfdjh akdfjh alkdsjf alksdjfh alksdfjh asdfjklh aslkdfhj aslkdfjh adfjkhl", :short => '-m', :long => '--multi', :type => :string, :multi => true
52
48
  end
53
49
 
54
- app.before do |command_name, global_options, command_options, arguments|
55
- #executes before each command
56
- end
57
-
58
- app.on_error do |error|
59
- #handle all errors here
50
+ app.action do |options, arguments|
51
+ puts "Action \nglobal options: #{options} \narguments: #{arguments}"
60
52
  end
61
53
  end
62
54
  ```
63
55
 
64
- That's all there is to it, now if your script is named `my_script` you'll be able to do things like:
56
+ If your file is called `app.rb` you is executable, you can then call it like this:
65
57
 
66
58
  ```
67
- my_script my_command
68
- my_script my_command foobar
69
- my_script my_command --no-do-stuff foobar
70
- my_script -g "blah" my_command --do-stuff foobar
59
+ ./app.rb
60
+ ./app.rb -h
61
+ ./app.rb -g "hello" foobar
62
+ ./app.rb -m "foo" -m "bar" --global="yadda" foobar
71
63
  ```
72
64
 
73
- That is all for now, just some DSL around Trollop to make your script look nice (hopefully more nice things to come).
65
+ ### Sub Commands
66
+
67
+ TODO
74
68
 
75
69
  ## Alternatives
76
70
 
77
- * [GLI](https://github.com/davetron5000/gli)
78
- * [Commander](https:/github.com/visionmedia/commander)
79
- * [CRI](https:/github.com/ddfreyne/cri)
80
- * [main](https:/github.com/ahoward/main)
81
- * [thor](https:/github.com/wycats/thor)
82
- * [slop](https:/github.com/injekt/slop)
71
+ * https://github.com/davetron5000/gli
72
+ * https://github.com/visionmedia/commander
73
+ * https://github.com/ddfreyne/cri
74
+ * https://github.com/ahoward/main
75
+ * https://github.com/wycats/thor
76
+ * https://github.com/injekt/slop
83
77
 
84
78
  ## Contributing
85
79
 
@@ -88,22 +82,3 @@ That is all for now, just some DSL around Trollop to make your script look nice
88
82
  3. Commit your changes (`git commit -am 'Add some feature'`)
89
83
  4. Push to the branch (`git push origin my-new-feature`)
90
84
  5. Create new Pull Request
91
-
92
- ### TODO
93
-
94
- - should be able to support command line apps without sub commands, just a plain vanilla command line app
95
- - should have the ability to generate a skeleton command line app according to my conventions
96
- - should be more config file aware but can live without it
97
- - work out if it needs to be involved in better logging support
98
- - should have better ability to create better help text
99
- - should have deal better with exit codes and stuff (read the book section about it)
100
- - maybe add some specs for it if needed
101
- - maybe add some cukes for it if needed
102
- - blog about what makes a good command line app (this and the one below are possibly one post)
103
- - blog about how to use escort and why the other libraries fall short
104
- - blog about how escort is constructed
105
- - should have ability to ask for user input for some commands, using highline or something like that
106
- - should have a clean structure convention of where code that executes the commands should live so that command line apps are easy
107
- - use escort to build a command line version of my markov chains name generator from ages ago
108
- - blog about using escort to build my name generator
109
- - ability to have a default command when you didn't specify one??? (what would this mean for sub command and non sub command apps)
data/TODO.md ADDED
@@ -0,0 +1,152 @@
1
+ ROADMAP
2
+
3
+ v0.1.0
4
+ - some spec infrastructure DONE
5
+ - a couple of basic specs DONE
6
+ - some integration test infrastructure DONE
7
+ - a couple of basic integration tests DONE
8
+ - pull classes for formatting out into files DONE
9
+ - summary and description for commands DONE
10
+ - include command summary and description in help formatter DONE
11
+ - rework how help is displayed for commands with summary and description DONE
12
+ - the sub commands for command should use summary instead of description DONE
13
+ - do for validation and action what I did for option within the dsl DONE
14
+ - look again at conflicts support in dsl, we can probably do better naming for it DONE
15
+ - up the version to 0.1.0
16
+ - tag and release
17
+
18
+ v0.9.0
19
+ - a few more tests
20
+ - a few more integration tests
21
+ - refactor the formatting code some more
22
+ - pull some formatting code into separate classes
23
+ - test some of the utility formatting code
24
+ - up the version to 0.9.0
25
+ - tag and release
26
+
27
+ v1.0.0
28
+ - rewrite the readme to explain:
29
+ - a basic app with no options
30
+ - a basic app with options
31
+ - supplying multiple of the same parameter using multi
32
+ - a basic app with require arguments
33
+ - a basic app specifying version, description and summary
34
+ - a basic app with options and validations
35
+ - implementing and action for a basic app
36
+ - a basic app with config file (don't worry about explaining all the helper stuff that gets created)
37
+ - a basic app with conflicting options
38
+ - a basic app with dependent options
39
+ - a command app with options, validations, description, summary, require arguments and config file
40
+ - a sub command app with options, validations, description, summary, require arguments and config file
41
+ - rework the examples again to show of some/most of the features (along the lines of the integration tests and readme)
42
+ - extract all the dsl command stuff into a helper module so that global and command can be handled by the same code
43
+ - up the version to 1.0.0
44
+ - tag and release
45
+ - get the blog updated with a new theme
46
+ - put a new subscriber count widget on blog
47
+ - blog Build Command-Line Apps Like a Pro Using Ruby and Escort
48
+
49
+ v1.0.1
50
+ - more specs (setup accessor etc)
51
+ - more integration specs (more specs for the different types of options)
52
+ - rework the integration specs and matchers so there are less moving parts (perhaps push some stuff down into a base class etc.)
53
+ - lots more logging at different levels for debug purposes
54
+ - add validation messages to help text
55
+ - a way have helpers available when you don't want to have to create a command
56
+ - the config auto option should not be included in the config file, same with other auto options
57
+ - readme about how to actually pass the user config through to action and the fact that regardless if you have a config file or not, you can have a config var or not as part of the block variables
58
+ - rewrite the help formatter to be a bit easier to understand (more like man output for output)
59
+ - add depends support to dsl
60
+
61
+ v1.0.2
62
+ - more specs
63
+ - scaffold for app with no sub commands
64
+ - scaffold for app with one level of commands
65
+ - scaffold for app with nested sub commands
66
+
67
+ v1.0.3
68
+ - an option for setup that indicates it is a project specific CLI app
69
+ - an options for setup that indicates it is an environment aware CLI app
70
+ - make the configuration environment aware
71
+ - make escort environment aware
72
+ - json configuration should support defaults config
73
+ - much better documentation and usage patterns
74
+ - pull the terminal formatting stuff into separate gem
75
+
76
+
77
+
78
+
79
+ BUCKET
80
+ - instead of before and after blocks, add before, after filters for commands, maybe
81
+ - when no action found in the context we want to execute, it should error or at least print an error
82
+ - can we flatten the configuration (as an option)
83
+ - can we extract the json configuration stuff into a separate gem
84
+ - json configuration should support having environment configs in multiple files
85
+ - blog the crap out of all aspects of how to use it, how it is constructed, some fancy things you can do with it etc.
86
+ - ability to ask for user input for a command (e.g. for passwords, this can possibly be done via validations)
87
+
88
+ - blog about what makes a good command line app (this and the one below are possibly one post)
89
+ - blog about how to use escort and why the other libraries possibly fall short
90
+ - blog about how escort is constructed
91
+ - blog about using escort to build a markov chains based name generator
92
+ - blog about creating a sub command based app using escort
93
+ - blog about creating an app with user input using escort
94
+ - blog about instance_eval and the fact that it doesn't do closure properly (why), and the trick from trollop for how to get it to accept arguments
95
+ - blog about exception hierarchy for apps, what exceptions to have, when to raise exceptions, touch on throw/catch and why they are bad/good, touch on exit codes for command line apps in the context of exception throwing
96
+ - blog about nested exceptions and how to make them nice in your app, also metion exceptional ruby book as well as nestegg gem
97
+ - blog about dependencies with bundler, the spermy operator and what version will be chosen
98
+ - blog about ppjson and how to use it
99
+
100
+ - improve the terminal formatter, allowing wrapping text to anywhere, and tabular like output without an actual table, allowing configuring terminal of any size not just 80, spin it off a little separate project, with an example of how to possibly build a menu in it or something
101
+ - BUG the help formatting is still not quite right as far as respecting the char limits and wrapping properly when doing tabular output!!!!
102
+ - do a readme for how trollop was slightly modified to accept a formatter DONE
103
+ - gemspec summary and description should be taken from the app definition/maybe
104
+ - perhaps add a copyright with license to readme
105
+ - via method missing we can make the dsl classes more robust by printing errors and exting when non-dsl methods are attempted
106
+ - configuring multi of multi
107
+ - how do we describe what the arguments should be??
108
+ - blog about the convention for implementing the escort actions
109
+ - ability to provide some default command line arguments via an environment variable
110
+
111
+
112
+ PIE IN SKY
113
+ - choosing default output format based on where the output is going STDOUT.tty?
114
+ - look at ruby curses support a bit more closely and maybe use that for terminal stuff instead as it would be much better at it
115
+
116
+
117
+
118
+ DONE
119
+ - create a tool to pretty print json (ppjson) using escort
120
+ - global config param if config file
121
+ - if app has a config, then give another param to control the extras creation, which will be an 'escort' sub command to allow manually creating and updating the config file etc.
122
+ - do all the other config file bits such as creating default, non-default and updating etc.
123
+ - catching all exceptions and dealing with them in a better way
124
+ - global verbose param always
125
+ - a global logger for escort which is accessible to commands etc.
126
+ - support an on_error block to allow user to control what happens when errors occur
127
+ - default option values via env variables (if necessary)
128
+ - instead of exiting and printing errors all over the place, just raise specific errors, and handle the printing and exiting in the handle block in app.rb
129
+ - options that are added by the system and not by the user should come at the end of the options list not sprinkled everywhere in help
130
+ - test the configuration loading and writing again
131
+ - get the coniguration updating working (two hashes should be merged, values both in hash1 and hash2 should be left alone, values in hash1, but not in hash2 should be deleted from hash1, values in hash2 but not in hash1 should be added to hash1)
132
+ - support for configuration files for your command line apps DONE
133
+ - the ability to set the config file name DONE
134
+ - ability to switch on and off default creation of config file DONE
135
+ - the ability to by default read a config file by walking up the directory tree DONE
136
+ - ability to configure global options and command specific options (through the file) DONE
137
+ - ability to configure extra user data that may be needed (through the file) DONE
138
+ - an option to read specific config file instead of the default DONE
139
+ - a flag to create a default config in a specific directory DONE
140
+ - config file options should be validated just like the command line options DONE
141
+ - configuring array :multi data via the configuration file DONE
142
+ - exception hierarchy for gem and better exit codes (better exception handling for the whole gem, UserError, LogicErrors(InternalError, ClientError), TransientError, no raise library api, tagging exceptions) DONE
143
+ - do a readme entry on exception handling and exit codes DONE
144
+ - provide version via configuration DONE
145
+ - automatically include version (not just version, automatically include commands in general) DONE
146
+ - better ways to create help text to override default trollop behaviour (use below as a default) DONE
147
+ - add default values to help text DONE
148
+ - refactor so that objects passed into the dsl only have dsl methods available to call DONE
149
+ - better support for before and after blocks with explanations and examples of usage N/A
150
+ - better support for on_error blocks with explanations and examples of usage (roll exit code support into here), default handling of errors in block N/A
151
+ - a convention for how to actually do the code that will handle the commands etc. DONE
152
+ - support for infinitely nesting sub commands (is this really necessary) DONE
@@ -8,10 +8,14 @@ Gem::Specification.new do |gem|
8
8
  gem.version = Escort::VERSION
9
9
  gem.authors = ["Alan Skorkin"]
10
10
  gem.email = ["alan@skorks.com"]
11
- gem.summary = %q{An escort is still a trollop just dressed up}
12
- gem.description = %q{Basically we take the excellent Trollop command line options parser and dress it up a little with some DSL to make writing CLI apps a bit nicer, but still retain the full power of the awesome Trollop.}
11
+ gem.summary = %q{A library that makes building command line apps in ruby so easy, you'll feel like an expert is guiding you through it}
12
+ gem.description = %q{Writing even complex command-line apps should be quick, easy and fun. Escort takes the excellent Trollop option parser and adds a whole bunch of awesome features to produce a library you will always want to turn to when a 'quick script' is in order.}
13
13
  gem.homepage = "https://github.com/skorks/escort"
14
14
 
15
+ gem.add_development_dependency('rspec')
16
+ gem.add_development_dependency('fakefs')
17
+ gem.add_development_dependency('rake')
18
+
15
19
  gem.files = `git ls-files`.split($/)
16
20
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
21
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ require File.expand_path(File.join(File.expand_path(__FILE__), "..", "..", "lib", "escort"))
3
+
4
+ Escort::App.create do |app|
5
+ app.version "0.2.5"
6
+
7
+ app.options do |opts|
8
+ opts.opt :global_option, "Global option", :short => '-g', :long => '--global', :type => :string, :default => "global"
9
+ opts.opt :multi_option, "Option that can be specified multiple times alksjdfh lakjdfh adf alksdfh alkdfjh alsdfjhaskdjfh alsdkfjh alksfdjh akdfjh alkdsjf alksdjfh alksdfjh asdfjklh aslkdfhj aslkdfjh adfjkhl", :short => '-m', :long => '--multi', :type => :string, :multi => true
10
+ end
11
+
12
+ app.action do |options, arguments|
13
+ puts "Action \nglobal options: #{options} \narguments: #{arguments}"
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ require File.expand_path(File.join(File.expand_path(__FILE__), "..", "..", "lib", "escort"))
3
+
4
+ Escort::App.create do |app|
5
+ app.requires_arguments
6
+
7
+ app.options do |opts|
8
+ opts.opt :global_option, "Global option", :short => '-g', :long => '--global', :type => :string, :default => "global"
9
+ opts.opt :multi_option, "Option that can be specified multiple times alksjdfh lakjdfh adf alksdfh alkdfjh alsdfjhaskdjfh alsdkfjh alksfdjh akdfjh alkdsjf alksdjfh alksdfjh asdfjklh aslkdfhj aslkdfjh adfjkhl", :short => '-m', :long => '--multi', :type => :string, :multi => true
10
+ end
11
+
12
+ app.action do |options, arguments|
13
+ puts "Action \nglobal options: #{options} \narguments: #{arguments}"
14
+ end
15
+ end
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env ruby
2
+ require File.expand_path(File.join(File.expand_path(__FILE__), "..", "..", "lib", "escort"))
3
+
4
+ Escort::App.create do |app|
5
+ app.options do |opts|
6
+ opts.opt :global_option, "Global option", :short => '-g', :long => '--global', :type => :string, :default => "global"
7
+ end
8
+
9
+ app.command :my_command, :description => "KJHLKJH askj aldkjfhakldfjh akdjfh alkdfhj alkdjhf alkjsdhf alkjsdhf aklsjdhf aklsjdhf akljdhf alkdjfh" do |command|
10
+ command.options do |opts|
11
+ opts.opt :do_stuff, "Do stuff", :short => :none, :long => '--do-stuff', :type => :boolean, :default => true
12
+ end
13
+
14
+ command.action do |options, arguments|
15
+ puts "Action for my_command\noptions: #{options} \narguments: #{arguments}"
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env ruby
2
+ require File.expand_path(File.join(File.expand_path(__FILE__), "..", "..", "lib", "escort"))
3
+
4
+ Escort::App.create do |app|
5
+ app.options do |opts|
6
+ opts.opt :global_option, "Global option", :short => '-g', :long => '--global', :type => :string, :default => "global"
7
+ end
8
+
9
+ app.command :my_command, :description => "KJHLKJH askj aldkjfhakldfjh akdjfh alkdfhj alkdjhf alkjsdhf alkjsdhf aklsjdhf aklsjdhf akljdhf alkdjfh" do |command|
10
+ command.requires_arguments
11
+
12
+ command.options do |opts|
13
+ opts.opt :do_stuff, "Do stuff", :short => :none, :long => '--do-stuff', :type => :boolean, :default => true
14
+ end
15
+
16
+ command.action do |options, arguments|
17
+ puts "Action for my_command\noptions: #{options} \narguments: #{arguments}"
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env ruby
2
+ require File.expand_path(File.join(File.expand_path(__FILE__), "..", "..", "lib", "escort"))
3
+
4
+ Escort::App.create do |app|
5
+ app.options do |opts|
6
+ opts.opt :global_option, "Global option", :short => '-g', :long => '--global', :type => :string, :default => "global"
7
+ end
8
+
9
+ app.command :my_command, :description => "KJHLKJH askj aldkjfhakldfjh akdjfh alkdfhj alkdjhf alkjsdhf alkjsdhf aklsjdhf aklsjdhf akljdhf alkdjfh" do |command|
10
+ command.requires_arguments
11
+
12
+ command.options do |opts|
13
+ opts.opt :do_stuff, "Do stuff", :short => :none, :long => '--do-stuff', :type => :boolean, :default => true
14
+ end
15
+
16
+ command.action do |options, arguments|
17
+ puts "Action for my_command\noptions: #{options} \narguments: #{arguments}"
18
+ end
19
+
20
+ command.command :nested_command, :description => "A nested sub command" do |command|
21
+ command.action do |options, arguments|
22
+ puts "Action for my_command nested_command\noptions: #{options} \narguments: #{arguments}"
23
+ end
24
+ end
25
+ end
26
+ end