diff --git a/Gemfile b/Gemfile index 50c5abe..a2ea974 100644 --- a/Gemfile +++ b/Gemfile @@ -9,10 +9,10 @@ platform :jruby do end # Ronin dependencies: -# gem 'ronin-core', '~> 0.1', github: "ronin-rb/ronin-core", -# branch: 'main' +gem 'ronin-core', '~> 0.2', github: 'ronin-rb/ronin-core', + branch: '0.2.0' -# gem 'command_kit', '~> 0.4', github: 'postmodern/command_kit.rb', +# gem 'command_kit', '~> 0.5', github: 'postmodern/command_kit.rb', # branch: 'main' group :development do diff --git a/README.md b/README.md index b2e8bad..f6d0403 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,7 @@ Arguments: [ARGS ...] Additional arguments for the command Commands: + completion help install list, ls @@ -112,7 +113,7 @@ Rnnin::Repos.glob("wordlists/*.txt") ## Requirements * [Ruby] >= 3.0.0 -* [ronin-core] ~> 0.1 +* [ronin-core] ~> 0.2 ## Install diff --git a/gemspec.yml b/gemspec.yml index 15a1fd3..3172b6f 100644 --- a/gemspec.yml +++ b/gemspec.yml @@ -20,6 +20,7 @@ metadata: generated_files: - data/completions/ronin-repos - man/ronin-repos.1 + - man/ronin-repos-completion.1 - man/ronin-repos-install.1 - man/ronin-repos-list.1 - man/ronin-repos-new.1 diff --git a/lib/ronin/repos/cli/commands/completion.rb b/lib/ronin/repos/cli/commands/completion.rb new file mode 100644 index 0000000..2e20d37 --- /dev/null +++ b/lib/ronin/repos/cli/commands/completion.rb @@ -0,0 +1,57 @@ +# frozen_string_literal: true +# +# Copyright (c) 2021-2023 Hal Brodigan (postmodern.mod3 at gmail.com) +# +# ronin-repos is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License as published +# by the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# ronin-repos is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with ronin-repos. If not, see . +# + +require 'ronin/repos/root' +require 'ronin/core/cli/completion_command' + +module Ronin + module Repos + class CLI + module Commands + # + # ## Usage + # + # ronin-repos completion [options] + # + # ## Options + # + # --print Prints the shell completion file + # --install Installs the shell completion file + # --uninstall Uninstalls the shell completion file + # -h, --help Print help information + # + # ## Examples + # + # ronin-repos completion --print + # ronin-repos completion --install + # ronin-repos completion --uninstall + # + # @since 0.2.0 + # + class Completion < Core::CLI::CompletionCommand + + completion_file File.join(ROOT,'data','completions','ronin-repos') + + man_dir File.join(ROOT,'man') + man_page 'ronin-repos-completion.1' + + end + end + end + end +end diff --git a/man/ronin-repos-completion.1.md b/man/ronin-repos-completion.1.md new file mode 100644 index 0000000..a7ce2ef --- /dev/null +++ b/man/ronin-repos-completion.1.md @@ -0,0 +1,78 @@ +# ronin-repos-completion 1 "2024-01-01" Ronin Repos "User Manuals" + +## NAME + +ronin-repos-completion - Manages shell completion rules for `ronin-repos` + +## SYNOPSIS + +`ronin-repos completion` [*options*] + +## DESCRIPTION + +The `ronin-repos completion` command can print, install, or uninstall shell +completion rules for the `ronin-repos` command. + +Supports installing completion rules for Bash or Zsh shells. +Completion rules for the Fish shell is currently not supported. + +### ZSH SUPPORT + +Zsh users will have to add the following lines to their `~/.zshrc` file in +order to enable Zsh's Bash completion compatibility layer: + + autoload -Uz +X compinit && compinit + autoload -Uz +X bashcompinit && bashcompinit + +## OPTIONS + +`--print` +: Prints the shell completion file. + +`--install` +: Installs the shell completion file. + +`--uninstall` +: Uninstalls the shell completion file. + +`-h`, `--help` +: Prints help information. + +## ENVIRONMENT + +*PREFIX* +: Specifies the root prefix for the file system. + +*HOME* +: Specifies the home directory of the user. Ronin will search for the + `~/.cache/ronin-repos` cache directory within the home directory. + +*XDG_DATA_HOME* +: Specifies the data directory to use. Defaults to `$HOME/.local/share`. + +## FILES + +`~/.local/share/bash-completion/completions/` +: The user-local installation directory for Bash completion files. + +`/usr/local/share/bash-completion/completions/` +: The system-wide installation directory for Bash completions files. + +`/usr/local/share/zsh/site-functions/` +: The installation directory for Zsh completion files. + +## EXAMPLES + +`ronin-repos completion --print` +: Prints the shell completion rules instead of installing them. + +`ronin-repos completion --install` +: Installs the shell completion rules for `ronin-repos`. + +`ronin-repos completion --uninstall` +: Uninstalls the shell completion rules for `ronin-repos`. + +## AUTHOR + +Postmodern + diff --git a/man/ronin-repos.1.md b/man/ronin-repos.1.md index a80f9c3..4d6656a 100644 --- a/man/ronin-repos.1.md +++ b/man/ronin-repos.1.md @@ -38,4 +38,4 @@ Postmodern ## SEE ALSO -[ronin-repos-install](ronin-repos-install.1.md) [ronin-repos-list](ronin-repos-list.1.md) [ronin-repos-remove](ronin-repos-remove.1.md) [ronin-repos-update](ronin-repos-update.1.md) [ronin-repos-purge](ronin-repos-purge.1.md) +[ronin-repos-completion](ronin-repos-completion.1.md) [ronin-repos-install](ronin-repos-install.1.md) [ronin-repos-list](ronin-repos-list.1.md) [ronin-repos-remove](ronin-repos-remove.1.md) [ronin-repos-update](ronin-repos-update.1.md) [ronin-repos-purge](ronin-repos-purge.1.md)