Skip to content

Commit 761f012

Browse files
committed
Added the ronin-listener completion command (closes #8).
1 parent c9c03f1 commit 761f012

File tree

6 files changed

+167
-3
lines changed

6 files changed

+167
-3
lines changed

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ platform :jruby do
99
end
1010

1111
# Ronin dependencies
12-
gem 'ronin-core', '~> 0.1', github: 'ronin-rb/ronin-core',
12+
gem 'ronin-core', '~> 0.2', github: 'ronin-rb/ronin-core',
1313
branch: '0.2.0'
1414
gem 'ronin-listener-dns', '~> 0.1', github: 'ronin-rb/ronin-listener-dns',
1515
branch: 'main'

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ ronin-listener new http file.rb
7777
* [Ruby] >= 3.0.0
7878
* [ronin-listener-dns] ~> 0.1
7979
* [ronin-listener-http] ~> 0.1
80-
* [ronin-core] ~> 0.1
80+
* [ronin-core] ~> 0.2
8181

8282
## Install
8383

gemspec.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ metadata:
2020
generated_files:
2121
- data/completions/ronin-listener
2222
- man/ronin-listener.1
23+
- man/ronin-listener-completion.1
2324
- man/ronin-listener-dns.1
2425
- man/ronin-listener-http.1
2526
- man/ronin-listener-new.1
@@ -32,7 +33,7 @@ dependencies:
3233
# Ronin dependencies:
3334
ronin-listener-dns: ~> 0.1
3435
ronin-listener-http: ~> 0.1
35-
ronin-core: ~> 0.1
36+
ronin-core: ~> 0.2
3637

3738
development_dependencies:
3839
bundler: ~> 2.0
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# frozen_string_literal: true
2+
#
3+
# ronin-listener - A Ruby CLI utility for receiving exfiltrated data.
4+
#
5+
# Copyright (c) 2023 Hal Brodigan (postmodern.mod3@gmail.com)
6+
#
7+
# ronin-listener is free software: you can redistribute it and/or modify
8+
# it under the terms of the GNU Lesser General Public License as published
9+
# by the Free Software Foundation, either version 3 of the License, or
10+
# (at your option) any later version.
11+
#
12+
# ronin-listener is distributed in the hope that it will be useful,
13+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
# GNU Lesser General Public License for more details.
16+
#
17+
# You should have received a copy of the GNU Lesser General Public License
18+
# along with ronin-listener. If not, see <https://www.gnu.org/licenses/>.
19+
#
20+
21+
require 'ronin/listener/root'
22+
require 'ronin/core/cli/completion_command'
23+
24+
module Ronin
25+
module Listener
26+
class CLI
27+
module Commands
28+
#
29+
# Manages the shell completion rules for `ronin-listener`.
30+
#
31+
# ## Usage
32+
#
33+
# ronin-listener completion [options]
34+
#
35+
# ## Options
36+
#
37+
# --print Prints the shell completion file
38+
# --install Installs the shell completion file
39+
# --uninstall Uninstalls the shell completion file
40+
# -h, --help Print help information
41+
#
42+
# ## Examples
43+
#
44+
# ronin-listener completion --print
45+
# ronin-listener completion --install
46+
# ronin-listener completion --uninstall
47+
#
48+
# @since 0.2.0
49+
#
50+
class Completion < Core::CLI::CompletionCommand
51+
52+
completion_file File.join(ROOT,'data','completions','ronin-listener')
53+
54+
man_dir File.join(ROOT,'man')
55+
man_page 'ronin-listener-completion.1'
56+
57+
description 'Manages the shell completion rules for ronin-listener'
58+
59+
end
60+
end
61+
end
62+
end
63+
end

man/ronin-listener-completion.1.md

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# ronin-listener-completion 1 "2024-01-01" Ronin Repos "User Manuals"
2+
3+
## NAME
4+
5+
ronin-listener-completion - Manages shell completion rules for `ronin-listener`
6+
7+
## SYNOPSIS
8+
9+
`ronin-listener completion` [*options*]
10+
11+
## DESCRIPTION
12+
13+
The `ronin-listener completion` command can print, install, or uninstall shell
14+
completion rules for the `ronin-listener` command.
15+
16+
Supports installing completion rules for Bash or Zsh shells.
17+
Completion rules for the Fish shell is currently not supported.
18+
19+
### ZSH SUPPORT
20+
21+
Zsh users will have to add the following lines to their `~/.zshrc` file in
22+
order to enable Zsh's Bash completion compatibility layer:
23+
24+
autoload -Uz +X compinit && compinit
25+
autoload -Uz +X bashcompinit && bashcompinit
26+
27+
## OPTIONS
28+
29+
`--print`
30+
: Prints the shell completion file.
31+
32+
`--install`
33+
: Installs the shell completion file.
34+
35+
`--uninstall`
36+
: Uninstalls the shell completion file.
37+
38+
`-h`, `--help`
39+
: Prints help information.
40+
41+
## ENVIRONMENT
42+
43+
*PREFIX*
44+
: Specifies the root prefix for the file system.
45+
46+
*HOME*
47+
: Specifies the home directory of the user. Ronin will search for the
48+
`~/.cache/ronin-listener` cache directory within the home directory.
49+
50+
*XDG_DATA_HOME*
51+
: Specifies the data directory to use. Defaults to `$HOME/.local/share`.
52+
53+
## FILES
54+
55+
`~/.local/share/bash-completion/completions/`
56+
: The user-local installation directory for Bash completion files.
57+
58+
`/usr/local/share/bash-completion/completions/`
59+
: The system-wide installation directory for Bash completions files.
60+
61+
`/usr/local/share/zsh/site-functions/`
62+
: The installation directory for Zsh completion files.
63+
64+
## EXAMPLES
65+
66+
`ronin-listener completion --print`
67+
: Prints the shell completion rules instead of installing them.
68+
69+
`ronin-listener completion --install`
70+
: Installs the shell completion rules for `ronin-listener`.
71+
72+
`ronin-listener completion --uninstall`
73+
: Uninstalls the shell completion rules for `ronin-listener`.
74+
75+
## AUTHOR
76+
77+
Postmodern <postmodern.mod3@gmail.com>
78+

spec/cli/commands/completion_spec.rb

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
require 'spec_helper'
2+
require 'ronin/listener/cli/commands/completion'
3+
require_relative 'man_page_example'
4+
5+
describe Ronin::Listener::CLI::Commands::Completion do
6+
it "must inherit from Ronin::Core::CLI::CompletionCommand" do
7+
expect(described_class).to be < Ronin::Core::CLI::CompletionCommand
8+
end
9+
10+
it "must set completion_file" do
11+
expect(described_class.completion_file).to eq(
12+
File.join(Ronin::Listener::ROOT,'data','completions','ronin-listener')
13+
)
14+
end
15+
16+
it "must set man_dir" do
17+
expect(described_class.man_dir).to_not be(nil)
18+
expect(File.directory?(described_class.man_dir)).to be(true)
19+
end
20+
21+
include_examples "man_page"
22+
end

0 commit comments

Comments
 (0)