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,31 @@
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
+ opts.opt :multi_option, "Option that can be specified multiple times", :short => '-m', :long => '--multi', :type => :string, :multi => true
8
+ opts.opt :a_number, "Do stuff", :short => "-n", :long => '--number', :type => :int
9
+ end
10
+
11
+ app.validations do |opts|
12
+ opts.validate(:global_option, "must be either 'global' or 'local'") { |option| ["global", "local"].include?(option) }
13
+ opts.validate(:a_number, "must be between 10 and 20 exclusive") { |option| option > 10 && option < 20 }
14
+ end
15
+
16
+ app.command :my_command do |command|
17
+ command.options do |opts|
18
+ opts.opt :do_stuff, "Do stuff", :short => :none, :long => '--do-stuff', :type => :boolean, :default => true
19
+ opts.opt :string_with_format, "String with format", :short => "-f", :long => '--format', :type => :string, :default => "blah yadda11111111111"
20
+ end
21
+
22
+ command.validations do |opts|
23
+ opts.validate(:string_with_format, "should be at least two words") {|option| option =~ /\w\s\w/}
24
+ opts.validate(:string_with_format, "should be at least 20 characters long") {|option| option.length >= 20}
25
+ end
26
+
27
+ command.action do |options, arguments|
28
+ puts "Action for my_command\noptions: #{options} \narguments: #{arguments}"
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,42 @@
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
+ 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
8
+ end
9
+
10
+ app.config_file ".apprc", :autocreate => true
11
+
12
+ app.summary "Sum1"
13
+ app.description "Desc1"
14
+
15
+ app.command :my_command, :description => "KJHLKJH askj aldkjfhakldfjh akdjfh alkdfhj alkdjhf alkjsdhf alkjsdhf aklsjdhf aklsjdhf akljdhf alkdjfh", :aliases => [:my1, :my2] do |command|
16
+ #command.requires_arguments
17
+ command.summary "Sum2"
18
+ command.description "Desc2"
19
+
20
+ command.options do |opts|
21
+ opts.opt :do_stuff, "Do stuff", :short => :none, :long => '--do-stuff', :type => :boolean, :default => true
22
+ end
23
+
24
+ command.action do |options, arguments|
25
+ puts "Action for my_command\noptions: #{options} \narguments: #{arguments}"
26
+ end
27
+
28
+ command.command :nested_command, :description => "A nested sub command" do |command|
29
+ command.options do |opts|
30
+ opts.opt :do_stuff, "Do stuff", :short => :none, :long => '--do-stuff', :type => :boolean, :default => true
31
+ end
32
+
33
+ command.action do |options, arguments|
34
+ puts "Action for my_command nested_command\noptions: #{options} \narguments: #{arguments}"
35
+ end
36
+ end
37
+ end
38
+
39
+ app.action do |options, arguments, config|
40
+ puts "Action \nglobal options: #{options} \narguments: #{arguments}\nconfig: #{config}"
41
+ end
42
+ end
@@ -0,0 +1,12 @@
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
6
+ opt :global_option, "Global option", :short => '-g', :long => '--global', :type => :string, :default => "global"
7
+ end
8
+
9
+ app.action do |global_options, arguments|
10
+ puts "Action for my_command\nglobal options: #{global_options} \narguments: #{arguments}"
11
+ end
12
+ 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
6
+ opt :global_option, "Global option", :short => '-g', :long => '--global', :type => :string, :default => "global"
7
+ end
8
+
9
+ app.command :my_command do |command|
10
+ command.options do
11
+ opt :do_stuff, "Do stuff", :short => :none, :long => '--do-stuff', :type => :boolean, :default => true
12
+ end
13
+
14
+ command.action do |global_options, command_options, arguments|
15
+ puts "Action for my_command\nglobal options: #{global_options} \ncommand options: #{command_options}\narguments: #{arguments}"
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,14 @@
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.valid_with_no_arguments
6
+
7
+ app.options do
8
+ opt :global_option, "Global option", :short => '-g', :long => '--global', :type => :string, :default => "global"
9
+ end
10
+
11
+ app.action do |global_options, arguments|
12
+ puts "Action for my_command\nglobal options: #{global_options} \narguments: #{arguments}"
13
+ end
14
+ 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.valid_with_no_arguments
6
+
7
+ app.options do
8
+ opt :global_option, "Global option", :short => '-g', :long => '--global', :type => :string, :default => "global"
9
+ end
10
+
11
+ app.command :my_command do |command|
12
+ command.options do
13
+ opt :do_stuff, "Do stuff", :short => :none, :long => '--do-stuff', :type => :boolean, :default => true
14
+ end
15
+
16
+ command.action do |global_options, command_options, arguments|
17
+ puts "Action for my_command\nglobal options: #{global_options} \ncommand options: #{command_options}\narguments: #{arguments}"
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,16 @@
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.4"
6
+ #app.format_help_with(:default_formatter)
7
+
8
+ app.options do
9
+ opt :global_option, "Global option", :short => '-g', :long => '--global', :type => :string, :default => "global"
10
+ 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
11
+ end
12
+
13
+ app.action do |options, arguments|
14
+ puts "Action for my_command\nglobal options: #{options} \narguments: #{arguments}"
15
+ end
16
+ end
@@ -0,0 +1,31 @@
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.summary "An app that does crazy things"
6
+ #app.description "An app that asdfk df;adf a;df a;dfj a;df a;ldfkj a;lksdjf a;ldjf a;lfdj a;lsdfkj a;ldsfjk a;lksdfj a;lskdfj a;lkdfj a;ldfkj a;ldfjk a;ldfkj adf"
7
+
8
+ app.options do
9
+ opt :global_option, "Global option", :short => '-g', :long => '--global', :type => :string, :default => "global"
10
+ end
11
+
12
+ app.command :my_command, :description => "Command that does stuff", :aliases => [:mc, :mooc] do |command|
13
+ command.options do
14
+ opt :do_stuff, "Do stuff", :short => :none, :long => '--do-stuff', :type => :boolean, :default => true
15
+ end
16
+
17
+ command.action do |global_options, command_options, arguments|
18
+ puts "Action for my_command\nglobal options: #{global_options} \ncommand options: #{command_options}\narguments: #{arguments}"
19
+ end
20
+ end
21
+
22
+ app.command :blah, :description => "Command that does stuff adlkfjal;sdf alsdkjfa;ldkfj a;lsdfjk a;lsdfj a;ldkfj a;ldfkj a;lsdfj a;lfdjk" do |command|
23
+ command.options do
24
+ opt :do_stuff, "Do stuff", :short => :none, :long => '--do-stuff', :type => :boolean, :default => true
25
+ end
26
+
27
+ command.action do |global_options, command_options, arguments|
28
+ puts "Action for my_command\nglobal options: #{global_options} \ncommand options: #{command_options}\narguments: #{arguments}"
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,16 @@
1
+ {
2
+ "global_options": {
3
+ "global_option": "local",
4
+ "another_option": "world",
5
+ "blah": true
6
+ },
7
+ "command_options": {
8
+ "my_command": {
9
+ "command_option": "foo"
10
+ }
11
+ },
12
+ "user_data": {
13
+ "hello": "world",
14
+ "foo": null
15
+ }
16
+ }
@@ -0,0 +1,78 @@
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.summary "An app that does crazy things"
6
+ app.description "An app that asdfk df;adf a;df a;dfj a;df a;ldfkj a;lksdjf a;ldjf a;lfdj a;lsdfkj a;ldsfjk a;lksdfj a;lskdfj a;lkdfj a;ldfkj a;ldfjk a;ldfkj adf"
7
+
8
+ #app.config_file ".apprc", :autocreate => true
9
+
10
+ app.options do
11
+ opt :global_option, "Global option", :short => '-g', :long => '--global', :type => :string, :default => "global"
12
+ opt :another_option, "Another option", :short => '-a', :long => '--another', :type => :string, :default => "hello"
13
+ opt :blah, "Blah options", :short => '-b', :long => '--blah', :type => :flag
14
+ end
15
+
16
+ app.validations do |opts|
17
+ opts.validate(:global_option, "must be either 'global' or 'local'") { |option| ["global", "local"].include?(option) }
18
+ end
19
+
20
+ app.action do |global_options, arguments, config|
21
+ puts "Action for my_command\nglobal options: #{global_options} \narguments: #{arguments}\nuser config data: #{config}"
22
+ #puts "Action for my_command\nglobal options: #{global_options} \narguments: #{arguments}"
23
+ end
24
+ end
25
+
26
+ #config file is loaded automatically if it exists by walking up the directory tree when config file is specified DONE
27
+ #values from config file are merged into the parser correctly for global DONE
28
+ #values from config file are correctly overriden by those provided on the command line DONE
29
+ #values from config file get validated correctly DONE
30
+ #values from config file are merged into the parser correctly for commands DONE
31
+ #user config data can be passed through to action handling code DONE
32
+ #
33
+ #config file automatically gets created in user home directory when autocreate is true
34
+ #when config file is automatically created all the global and command options get put in there with default values
35
+ #when option --config get specified the provided config file is loaded as the default config file then execution continues
36
+ #when option --create-default-config is specified and autocreate is false a default config file is created, if it doesn't exist yet, before being read and execution continues
37
+ #when option --create-config is specified a config file with that name and default values is created, if it doesn't exit yet, before being read and execution continues
38
+ #another global option needs to be created to allow user to set it to be notified which config file if any is being used for this session
39
+
40
+ #app.rb --create-config = './yaddarc'
41
+ #app.rb --config = './yaddarc'
42
+
43
+ #- ability to switch on and off default creation of config file X
44
+ #- an option to read specific config file instead of the default X
45
+ #- a flag to create a default config in a specific directory X
46
+ #- the ability to by default read a config file by walking up the directory tree X
47
+ #- config file options should be validated just like the command line options ??
48
+ #- ability to configure global options and command specific options (through the file) ??
49
+ #- ability to configure extra user data that may be needed (through the file) ??
50
+ #how will we pass the user level configuration up to handling code???
51
+
52
+ #by default no configuration file at all DONE
53
+ #if config_file was configured on the app DONE
54
+ # the app gets a global --config options which takes a path of file to use as configuration file
55
+ # the app gets a global --create-config which can have a path passed to it which will mean it creates a file with that name
56
+ # the app gets a global --create-default-config option which is a flag meaning it will create a file in home director with default name
57
+ #if config_file specified and auto_create false DONE
58
+ #program will attempt to look for file by walking up the directory tree on every invocation DONE
59
+ #but file never gets automatically created DONE
60
+ #if config_file specified and auto_create true
61
+ #program will attempt to look for file by walking up the directory tree on every invocation
62
+ #if it doesn't exist when app is run then file gets created with some default values in the user home directory
63
+ #autoloading only works with files that are default named if custom named config file is created either manually or through --create-config then you can only used it via the --config global option, this is obvious
64
+ #creating a default named config file via --create-config without passing in a path will allow you to run the script from that directory and have that file picked up in preference to anyother config file lower down in the directory tree (e.g. in the home directory), this way you can have the script installed globally and run it from different directories with different default options
65
+ #config file format will be json:
66
+ #{
67
+ #:global_options => {
68
+ #},
69
+ #:command_options => {
70
+ #:my_command => {
71
+ #},
72
+ #:blah_command => {
73
+ #}
74
+ #},
75
+ #:user_data => {
76
+ #}
77
+ #}
78
+ #need to validate the options parts of the config file to make sure there is no rubbish in there
@@ -0,0 +1,35 @@
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.summary "An app that does crazy things"
6
+ app.description "An app that asdfk df;adf a;df a;dfj a;df a;ldfkj a;lksdjf a;ldjf a;lfdj a;lsdfkj a;ldsfjk a;lksdfj a;lskdfj a;lkdfj a;ldfkj a;ldfjk a;ldfkj adf"
7
+
8
+ app.config_file ".apprc"#, :autocreate => true
9
+
10
+ app.options do
11
+ opt :global_option, "Global option", :short => '-g', :long => '--global', :type => :string, :default => "global"
12
+ opt :another_option, "Another option", :short => '-a', :long => '--another', :type => :string, :default => "hello"
13
+ opt :blah, "Blah options", :short => '-b', :long => '--blah', :type => :flag
14
+ end
15
+
16
+ app.validations do |opts|
17
+ opts.validate(:global_option, "must be either 'global' or 'local'") { |option| ["global", "local"].include?(option) }
18
+ end
19
+
20
+ app.command :my_command, :description => "KJHLKJH askj aldkjfhakldfjh akdjfh alkdfhj alkdjhf alkjsdhf alkjsdhf aklsjdhf aklsjdhf akljdhf alkdjfh" do |command|
21
+ command.options do
22
+ opt :command_option, "Command option", :short => '-c', :long => '--command', :type => :string, :default => "blah"
23
+ opt :do_stuff, "Do stuff", :short => :none, :long => '--do-stuff', :type => :boolean, :default => true
24
+ end
25
+
26
+ command.action do |global_options, command_options, arguments, config|
27
+ puts "Action for my_command\nglobal options: #{global_options} \ncommand options: #{command_options}\narguments: #{arguments}\nuser config data: #{config}"
28
+ end
29
+ end
30
+
31
+ #app.action do |global_options, arguments, config|
32
+ #puts "Action for my_command\nglobal options: #{global_options} \narguments: #{arguments}\nuser config data: #{config}"
33
+ ##puts "Action for my_command\nglobal options: #{global_options} \narguments: #{arguments}"
34
+ #end
35
+ 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.default "-g 'local' my_command --no-do-stuff foobar"
6
+
7
+ app.options do
8
+ opt :global_option, "Global option", :short => '-g', :long => '--global', :type => :string, :default => "global"
9
+ end
10
+
11
+ app.command :my_command do |command|
12
+ command.options do
13
+ opt :do_stuff, "Do stuff", :short => :none, :long => '--do-stuff', :type => :boolean, :default => true
14
+ end
15
+
16
+ command.action do |global_options, command_options, arguments|
17
+ puts "Action for my_command\nglobal options: #{global_options} \ncommand options: #{command_options}\narguments: #{arguments}"
18
+ end
19
+ end
20
+ 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
6
+ 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
11
+ opt :do_stuff, "Do stuff", :short => :none, :long => '--do-stuff', :type => :boolean, :default => true
12
+ end
13
+
14
+ command.action do |global_options, command_options, arguments|
15
+ puts "Action for my_command\nglobal options: #{global_options} \ncommand options: #{command_options}\narguments: #{arguments}"
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,31 @@
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
6
+ opt :global_option, "Global option", :short => '-g', :long => '--global', :type => :string, :default => "global"
7
+ opt :multi_option, "Option that can be specified multiple times", :short => '-m', :long => '--multi', :type => :string, :multi => true
8
+ opt :a_number, "Do stuff", :short => "-n", :long => '--number', :type => :int
9
+ end
10
+
11
+ app.validations do |opts|
12
+ opts.validate(:global_option, "must be either 'global' or 'local'") { |option| ["global", "local"].include?(option) }
13
+ opts.validate(:a_number, "must be between 10 and 20 exclusive") { |option| option > 10 && option < 20 }
14
+ end
15
+
16
+ app.command :my_command do |command|
17
+ command.options do
18
+ opt :do_stuff, "Do stuff", :short => :none, :long => '--do-stuff', :type => :boolean, :default => true
19
+ opt :string_with_format, "String with format", :short => "-f", :long => '--format', :type => :string, :default => "blah yadda11111111111"
20
+ end
21
+
22
+ command.validations do |opts|
23
+ opts.validate(:string_with_format, "should be two words") {|option| option =~ /\w\s\w/}
24
+ opts.validate(:string_with_format, "should be at least 20 characters long") {|option| option.length >= 20}
25
+ end
26
+
27
+ command.action do |global_options, command_options, arguments|
28
+ puts "Action for my_command\nglobal options: #{global_options} \ncommand options: #{command_options}\narguments: #{arguments}"
29
+ end
30
+ end
31
+ end
@@ -1,9 +1,56 @@
1
1
  require 'escort/version'
2
-
3
2
  require 'escort/trollop'
3
+ require 'escort/utils'
4
+ require 'escort/arguments'
5
+ require 'escort/logger'
6
+
7
+ require 'escort/error/error'
8
+
9
+ require 'escort/formatter/terminal'
10
+ require 'escort/formatter/string_splitter'
11
+ require 'escort/formatter/terminal_formatter'
12
+ require 'escort/formatter/borderless_table'
13
+ require 'escort/formatter/common'
14
+ require 'escort/formatter/default_help_formatter'
15
+
16
+ require 'escort/setup/dsl/options'
17
+ require 'escort/setup/dsl/action'
18
+ require 'escort/setup/dsl/validations'
19
+ require 'escort/setup/dsl/command'
20
+ require 'escort/setup/dsl/config_file'
21
+ require 'escort/setup/dsl/global'
22
+
23
+ require 'escort/setup/configuration/locator/base'
24
+ require 'escort/setup/configuration/locator/descending_to_home'
25
+ require 'escort/setup/configuration/merge_tool'
26
+ require 'escort/setup/configuration/instance'
27
+ require 'escort/setup/configuration/reader'
28
+ require 'escort/setup/configuration/writer'
29
+ require 'escort/setup/configuration/generator'
30
+ require 'escort/setup/configuration/loader'
31
+
32
+ require 'escort/setup_accessor'
4
33
 
5
- require 'escort/global_dsl'
6
- require 'escort/dsl'
34
+ require 'escort/validator'
35
+ require 'escort/auto_options'
36
+ require 'escort/global_pre_parser'
37
+ require 'escort/option_parser'
38
+
39
+ require 'escort/action_command/base'
40
+ require 'escort/action_command/escort_utility_command'
7
41
 
8
- require 'escort/command'
9
42
  require 'escort/app'
43
+
44
+ at_exit do
45
+ Escort::Logger.close
46
+ end
47
+
48
+ def error_logger
49
+ Escort::Logger.error
50
+ end
51
+
52
+ def output_logger
53
+ Escort::Logger.output
54
+ end
55
+
56
+