feat: add parser support for completion
This commit is contained in:
parent
b1567a1aa0
commit
093c9d2fa1
2 changed files with 7 additions and 1 deletions
|
@ -4,6 +4,7 @@ module GX::Parsers
|
||||||
class CompletionParser < AbstractParser
|
class CompletionParser < AbstractParser
|
||||||
def build(parser, ancestors, config)
|
def build(parser, ancestors, config)
|
||||||
breadcrumbs = ancestors + "completion"
|
breadcrumbs = ancestors + "completion"
|
||||||
|
# config.mode = Types::Mode::CompletionAutodetect
|
||||||
|
|
||||||
parser.banner = Utils.usage_line(
|
parser.banner = Utils.usage_line(
|
||||||
breadcrumbs,
|
breadcrumbs,
|
||||||
|
@ -13,10 +14,12 @@ module GX::Parsers
|
||||||
parser.separator("\nCompletion commands:")
|
parser.separator("\nCompletion commands:")
|
||||||
|
|
||||||
parser.on("--bash", "Generate bash completion") do |_|
|
parser.on("--bash", "Generate bash completion") do |_|
|
||||||
|
config.mode = Types::Mode::CompletionBash
|
||||||
Log.info { "Set bash completion" }
|
Log.info { "Set bash completion" }
|
||||||
end
|
end
|
||||||
|
|
||||||
parser.on("--zsh", "Generate zsh completion") do |_|
|
parser.on("--zsh", "Generate zsh completion") do |_|
|
||||||
|
config.mode = Types::Mode::CompletionZsh
|
||||||
Log.info { "Set zsh completion" }
|
Log.info { "Set zsh completion" }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -69,7 +69,10 @@ module GX::Parsers
|
||||||
# end
|
# end
|
||||||
|
|
||||||
parser.on("completion", "Manage completion") do
|
parser.on("completion", "Manage completion") do
|
||||||
config.mode = Types::Mode::GlobalCompletion
|
config.mode = Types::Mode::GlobalHelp
|
||||||
|
config.help_options = Parsers::Options::HelpOptions.new
|
||||||
|
config.help_options.try(&.parser_snapshot=(parser.dup))
|
||||||
|
|
||||||
Parsers::CompletionParser.new.build(parser, breadcrumbs, config)
|
Parsers::CompletionParser.new.build(parser, breadcrumbs, config)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue