Class: Topicz::Commands::PathCommand
- Inherits:
-
RepositoryCommand
- Object
- RepositoryCommand
- Topicz::Commands::PathCommand
- Defined in:
- lib/topicz/commands/path_command.rb
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(config_file = nil, arguments = []) ⇒ PathCommand
constructor
A new instance of PathCommand.
- #option_parser ⇒ Object
Methods inherited from RepositoryCommand
#find_exactly_one_topic, #load_config, #load_repository, #process_excludes
Constructor Details
#initialize(config_file = nil, arguments = []) ⇒ PathCommand
Returns a new instance of PathCommand.
8 9 10 11 12 13 |
# File 'lib/topicz/commands/path_command.rb', line 8 def initialize(config_file = nil, arguments = []) super(config_file) @strict = false option_parser.order! arguments @filter = arguments.join ' ' end |
Instance Method Details
#execute ⇒ Object
34 35 36 |
# File 'lib/topicz/commands/path_command.rb', line 34 def execute print find_exactly_one_topic(@filter, @strict).fullpath end |
#option_parser ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/topicz/commands/path_command.rb', line 15 def option_parser OptionParser.new do || . = 'Usage: path <filter>' .on('-s', '--strict', 'Do a full strict match on topic IDs only') do @strict = true end .separator '' .separator 'Prints the absolute path to the topic that matches <filter>.' .separator '' .separator 'The filter specifies the text to search on. The text is matched against the topic\'s: ' .separator '- path on the filesystem' .separator '- id, if specified in the topic\'s topic.yaml file' .separator '- title, if specified in the topic\'s topic.yaml file' .separator '- aliases, if specified in the topic\'s topic.yaml file' .separator '' .separator 'The filter must return precisely one topic. Zero or more matches give an error.' end end |