Class: Zomgit::Commands::FindCommand

Inherits:
BasicCommand show all
Includes:
Zomgit::Concerns::Findable
Defined in:
lib/zomgit/commands/find.rb

Constant Summary collapse

DESCRIPTION =
"Find files in the git repo"
SWITCHES =
{
  i(greedy g) => {
    default_value: true,
    negatable: true,
    desc: "Let the finder be greedy (less accurate, more results)"
  },
  i(G) => {
    default_value: false,
    negatable: false,
    desc: "Alias to --no-greedy",
  },
  i(r refine) => {
    default_value: false,
    negatable: false,
    desc: "Let the finder be selective (more accurate, less results)"
  }
}
FLAGS =
{
  i(filter f) => {
    arg_name: "filter",
    desc: "Limit the search to a specific state (tracked, untracked, etc)",
    must_match: %w(all untracked tracked unstaged staged modified)
  }
}

Instance Attribute Summary

Attributes inherited from BasicCommand

#arguments, #options

Instance Method Summary collapse

Methods included from Zomgit::Concerns::Findable

#search

Methods inherited from BasicCommand

#initialize

Constructor Details

This class inherits a constructor from Zomgit::Commands::BasicCommand

Instance Method Details

#findObject



33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/zomgit/commands/find.rb', line 33

def find
  if self.arguments.empty?
    raise Zomgit::Exceptions::MissingQueryError.new("You need to supply a search query!")
  end

  files = self.search(self.arguments, self.options)

  if files.empty?
    raise Zomgit::Exceptions::FileOrDirectoryNotFoundError.new("Nothing found matching your query")
  end

  files.join("\n")
end