Skip to content

Commit

Permalink
Added the --python option to ronin quote (closes #239).
Browse files Browse the repository at this point in the history
  • Loading branch information
postmodern committed Nov 23, 2024
1 parent 81e7ed7 commit 70c20ac
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/ronin/cli/commands/quote.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ module Commands
# -j, --js JavaScript quotes the data
# -S, --shell Quotes the data as a Shell String
# -P, --powershell Quotes the data as a PowerShell String
# --python Quotes the data as a Python String
# -R, --ruby Quotes the data as a Ruby String
# -h, --help Print help information
#
Expand Down Expand Up @@ -78,6 +79,11 @@ class Quote < StringMethodsCommand
@method_calls << :powershell_string
end

option :python, desc: 'Quotes the data as a Python String' do
require 'ronin/support/encoding/python'
@method_calls << :python_string
end

option :ruby, short: '-R',
desc: 'Quotes the data as a Ruby String' do
require 'ronin/support/encoding/ruby'
Expand Down
3 changes: 3 additions & 0 deletions man/ronin-quote.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ Produces quoted a string for a variety of programming languages.
`-P`, `--powershell`
: Quotes the data as a PowerShell String.

`--python`
: Quotes the data as a Python String.

`-R`, `--ruby`
: Quotes the data as a Ruby String.

Expand Down
12 changes: 12 additions & 0 deletions spec/cli/commands/quote_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,18 @@
end
end

describe "--python" do
let(:argv) { %w[--python] }

it "must require 'ronin/support/encoding/python'" do
expect(require('ronin/support/encoding/python')).to be(false)
end

it "must add :python_string to #method_calls" do
expect(subject.method_calls.last).to eq(:python_string)
end
end

describe "--ruby" do
let(:argv) { %w[--ruby] }

Expand Down

0 comments on commit 70c20ac

Please sign in to comment.