From b1567a1aa0c49ba766f333d14cb878cf1812f7ce Mon Sep 17 00:00:00 2001 From: Glenn Date: Sun, 4 Aug 2024 22:14:10 +0200 Subject: [PATCH] feat: add base classes for handling completion --- src/commands/completion_autodetect.cr | 17 +++++++++++++++++ src/commands/completion_bash.cr | 17 +++++++++++++++++ src/commands/completion_zsh.cr | 17 +++++++++++++++++ 3 files changed, 51 insertions(+) create mode 100644 src/commands/completion_autodetect.cr create mode 100644 src/commands/completion_bash.cr create mode 100644 src/commands/completion_zsh.cr diff --git a/src/commands/completion_autodetect.cr b/src/commands/completion_autodetect.cr new file mode 100644 index 0000000..8f413b8 --- /dev/null +++ b/src/commands/completion_autodetect.cr @@ -0,0 +1,17 @@ +require "./abstract_command" + +module GX::Commands + class CompletionAutodetect < AbstractCommand + def initialize(@config : GX::Config) + end + + def execute + STDERR.puts "FIXME: Completion auto-detection isn't implemented yet. Please select one of the following: --bash or --zsh" + exit(0) + end + + def self.handles_mode + GX::Types::Mode::CompletionAutodetect + end + end +end diff --git a/src/commands/completion_bash.cr b/src/commands/completion_bash.cr new file mode 100644 index 0000000..19c037c --- /dev/null +++ b/src/commands/completion_bash.cr @@ -0,0 +1,17 @@ +require "./abstract_command" + +module GX::Commands + class CompletionBash < AbstractCommand + def initialize(@config : GX::Config) + end + + def execute + completion_bash = FileStorage.get("completion.bash") + STDOUT.puts completion_bash.gets_to_end + end + + def self.handles_mode + GX::Types::Mode::CompletionBash + end + end +end diff --git a/src/commands/completion_zsh.cr b/src/commands/completion_zsh.cr new file mode 100644 index 0000000..f97c5ce --- /dev/null +++ b/src/commands/completion_zsh.cr @@ -0,0 +1,17 @@ +require "./abstract_command" + +module GX::Commands + class CompletionZsh < AbstractCommand + def initialize(@config : GX::Config) + end + + def execute + completion_bash = FileStorage.get("completion.zsh") + STDOUT.puts completion_bash.gets_to_end + end + + def self.handles_mode + GX::Types::Mode::CompletionZsh + end + end +end