Class: SuperDocopt::Base
- Inherits:
-
Object
- Object
- SuperDocopt::Base
- Includes:
- Singleton
- Defined in:
- lib/super_docopt/base.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#docopt ⇒ Object
Returns the value of attribute docopt.
-
#subcommands ⇒ Object
Returns the value of attribute subcommands.
-
#version ⇒ Object
Returns the value of attribute version.
Class Method Summary collapse
- .docopt(path) ⇒ Object
- .execute(argv = []) ⇒ Object
- .subcommands(list) ⇒ Object
- .version(version) ⇒ Object
Instance Method Summary collapse
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
8 9 10 |
# File 'lib/super_docopt/base.rb', line 8 def args @args end |
#docopt ⇒ Object
Returns the value of attribute docopt.
9 10 11 |
# File 'lib/super_docopt/base.rb', line 9 def docopt @docopt end |
#subcommands ⇒ Object
Returns the value of attribute subcommands.
9 10 11 |
# File 'lib/super_docopt/base.rb', line 9 def subcommands @subcommands end |
#version ⇒ Object
Returns the value of attribute version.
9 10 11 |
# File 'lib/super_docopt/base.rb', line 9 def version @version end |
Class Method Details
.docopt(path) ⇒ Object
19 20 21 |
# File 'lib/super_docopt/base.rb', line 19 def self.docopt(path) instance.docopt = path end |
.execute(argv = []) ⇒ Object
11 12 13 |
# File 'lib/super_docopt/base.rb', line 11 def self.execute(argv = []) instance.execute_cli argv end |
.subcommands(list) ⇒ Object
23 24 25 |
# File 'lib/super_docopt/base.rb', line 23 def self.subcommands(list) instance.subcommands = list end |
.version(version) ⇒ Object
15 16 17 |
# File 'lib/super_docopt/base.rb', line 15 def self.version(version) instance.version = version end |
Instance Method Details
#execute_cli(argv = []) ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'lib/super_docopt/base.rb', line 27 def execute_cli(argv = []) doc = File.read docopt begin @args = DocoptNG.docopt(doc, argv: argv, version: version) handle_subcommand rescue DocoptNG::Exit => e puts e. end end |