Class: D2::Commands::Cd
- Inherits:
-
D2::Command
- Object
- CLI::Kit::BaseCommand
- D2::Command
- D2::Commands::Cd
- Defined in:
- lib/d2/commands/cd.rb
Class Method Summary collapse
Instance Method Summary collapse
Methods included from Utils::Formatter
Class Method Details
Instance Method Details
#call(args, _name) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/d2/commands/cd.rb', line 7 def call(args, _name) # This find command will enumerate the src_path directory for all repos # Assumes src_path/PROVIDER.com/OWNER/REPO # Will return all `REPO` entries relative to the src path base_path = File.(D2::Config.get('src_path', 'default')) = D2::Helpers::Fzy.fuzzy_match( "find #{base_path}/*/* -type d -maxdepth 1 -mindepth 1 | sed -n 's|^#{base_path}||p'", query: args.shift, num_matches: 1 ) if .empty? logger.info "Nothing found for #{args.first}" else path = File.join(base_path, .first) D2::FILE_DESCRIPTOR.write("cd #{path}") end end |