-
-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
153 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
# frozen_string_literal: true | ||
# | ||
# Copyright (c) 2006-2024 Hal Brodigan (postmodern.mod3 at gmail.com) | ||
# | ||
# Ronin is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# Ronin 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 General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with Ronin. If not, see <https://www.gnu.org/licenses/>. | ||
# | ||
|
||
require 'ronin/cli/file_processor_command' | ||
require 'ronin/support/archive' | ||
|
||
module Ronin | ||
class CLI | ||
module Commands | ||
# | ||
# Archive the files. | ||
# | ||
# ## Usage | ||
# | ||
# ronin archive [option] [FILE ...] | ||
# | ||
# ## Options | ||
# | ||
# -f, --format tar|zip Archive format | ||
# -o, --output PATH Archived file path | ||
# | ||
# ## Arguments | ||
# | ||
# FILE ... Optional file(s) to archive | ||
# | ||
class Archive < FileProcessorCommand | ||
|
||
usage '[options] [FILE ...]' | ||
|
||
option :format, short: '-f', | ||
value: { | ||
type: [:tar, :zip], | ||
default: :zip | ||
}, | ||
desc: 'Archive format' | ||
|
||
option :output, short: '-o', | ||
value: { | ||
type: String, | ||
usage: 'PATH' | ||
}, | ||
desc: 'Archived file path' | ||
|
||
description 'Archive the data' | ||
|
||
man_page 'ronin-archive.1' | ||
|
||
# | ||
# Runs the `archive` sub-command. | ||
# | ||
# @param [Array<String>] files | ||
# File arguments. | ||
# | ||
def run(*files) | ||
unless options[:output] | ||
print_error "must specify the --output option" | ||
exit(-1) | ||
end | ||
|
||
unless files.empty? | ||
Ronin::Support::Archive.send(options[:format], options[:output]) do |archive| | ||
files.each do |file| | ||
archive.add_file(file) do |io| | ||
File.open(file, 'rb') do |opened_file| | ||
io.write(opened_file.readpartial(4096)) until opened_file.eof? | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# ronin-archive 1 "2024-01-18" Ronin "User Manuals" | ||
|
||
## NAME | ||
|
||
ronin-archive - Archive the files. | ||
|
||
## SYNOPSIS | ||
|
||
`ronin archive` [*options*] {`-o`,`--output` *PATH* } *FILE* ... | ||
|
||
## DESCRIPTION | ||
|
||
Archive the files. | ||
|
||
## ARGUMENTS | ||
|
||
*FILE* | ||
: A file to add to the output archive. | ||
|
||
## OPTIONS | ||
|
||
`-f`, `--format` `tar`\|`zip` | ||
: Archive format. | ||
|
||
`-o`, `--output` *PATH* | ||
: Path to the output file. | ||
|
||
## EXAMPLES | ||
|
||
Archive files using tar format: | ||
|
||
$ ronin archive -f tar -o archived.tar arch1.txt arch2.txt | ||
|
||
Archive files using zip format: | ||
|
||
$ ronin archive -f zip -o archived.zip arch1.txt arch2.txt | ||
|
||
## AUTHOR | ||
|
||
Postmodern <[email protected]> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -177,4 +177,4 @@ Postmodern <[email protected]> | |
|
||
## SEE ALSO | ||
|
||
[ronin-help](ronin-help.1.md) [ronin-asn](ronin-asn.1.md) [ronin-banner-grab](ronin-banner-grab.1.md) [ronin-bitflip](ronin-bitflip.1.md) [ronin-bitsquat](ronin-bitsquat.1.md) [ronin-cert-dump](ronin-cert-dump.1.md) [ronin-cert-gen](ronin-cert-gen.1.md) [ronin-cert-grab](ronin-cert-grab.1.md) [ronin-completion](ronin-completion.1.md) [ronin-decode](ronin-decode.1.md) [ronin-decrypt](ronin-decrypt.1.md) [ronin-dns](ronin-dns.1.md) [ronin-email-addr](ronin-email-addr.1.md) [ronin-encode](ronin-encode.1.md) [ronin-encrypt](ronin-encrypt.1.md) [ronin-entropy](ronin-entropy.1.md) [ronin-escape](ronin-escape.1.md) [ronin-extract](ronin-extract.1.md) [ronin-grep](ronin-grep.1.md) [ronin-hexdump](ronin-hexdump.1.md) [ronin-highlight](ronin-highlight.1.md) [ronin-hmac](ronin-hmac.1.md) [ronin-homoglyph](ronin-homoglyph.1.md) [ronin-host](ronin-host.1.md) [ronin-http](ronin-http.1.md) [ronin-ip](ronin-ip.1.md) [ronin-iprange](ronin-iprange.1.md) [ronin-irb](ronin-irb.1.md) [ronin-md5](ronin-md5.1.md) [ronin-netcat](ronin-netcat.1.md) [ronin-new](ronin-new.1.md) [ronin-pack](ronin-pack.1.md) [ronin-proxy](ronin-proxy.1.md) [ronin-public-suffix-list](ronin-public-suffix-list.1.md) [ronin-quote](ronin-quote.1.md) [ronin-rot](ronin-rot.1.md) [ronin-sha1](ronin-sha1.1.md) [ronin-sha256](ronin-sha256.1.md) [ronin-sha512](ronin-sha512.1.md) [ronin-strings](ronin-strings.1.md) [ronin-tips](ronin-tips.1.md) [ronin-tld-list](ronin-tld-list.1.md) [ronin-typo](ronin-typo.1.md) [ronin-typosquat](ronin-typosquat.1.md) [ronin-unescape](ronin-unescape.1.md) [ronin-unhexdump](ronin-unhexdump.1.md) [ronin-unpack](ronin-unpack.1.md) [ronin-unquote](ronin-unquote.1.md) [ronin-url](ronin-url.1.md) [ronin-xor](ronin-xor.1.md) | ||
[ronin-help](ronin-help.1.md) [ronin-archive](ronin-archive.1.md) [ronin-asn](ronin-asn.1.md) [ronin-banner-grab](ronin-banner-grab.1.md) [ronin-bitflip](ronin-bitflip.1.md) [ronin-bitsquat](ronin-bitsquat.1.md) [ronin-cert-dump](ronin-cert-dump.1.md) [ronin-cert-gen](ronin-cert-gen.1.md) [ronin-cert-grab](ronin-cert-grab.1.md) [ronin-completion](ronin-completion.1.md) [ronin-decode](ronin-decode.1.md) [ronin-decrypt](ronin-decrypt.1.md) [ronin-dns](ronin-dns.1.md) [ronin-email-addr](ronin-email-addr.1.md) [ronin-encode](ronin-encode.1.md) [ronin-encrypt](ronin-encrypt.1.md) [ronin-entropy](ronin-entropy.1.md) [ronin-escape](ronin-escape.1.md) [ronin-extract](ronin-extract.1.md) [ronin-grep](ronin-grep.1.md) [ronin-hexdump](ronin-hexdump.1.md) [ronin-highlight](ronin-highlight.1.md) [ronin-hmac](ronin-hmac.1.md) [ronin-homoglyph](ronin-homoglyph.1.md) [ronin-host](ronin-host.1.md) [ronin-http](ronin-http.1.md) [ronin-ip](ronin-ip.1.md) [ronin-iprange](ronin-iprange.1.md) [ronin-irb](ronin-irb.1.md) [ronin-md5](ronin-md5.1.md) [ronin-netcat](ronin-netcat.1.md) [ronin-new](ronin-new.1.md) [ronin-pack](ronin-pack.1.md) [ronin-proxy](ronin-proxy.1.md) [ronin-public-suffix-list](ronin-public-suffix-list.1.md) [ronin-quote](ronin-quote.1.md) [ronin-rot](ronin-rot.1.md) [ronin-sha1](ronin-sha1.1.md) [ronin-sha256](ronin-sha256.1.md) [ronin-sha512](ronin-sha512.1.md) [ronin-strings](ronin-strings.1.md) [ronin-tips](ronin-tips.1.md) [ronin-tld-list](ronin-tld-list.1.md) [ronin-typo](ronin-typo.1.md) [ronin-typosquat](ronin-typosquat.1.md) [ronin-unescape](ronin-unescape.1.md) [ronin-unhexdump](ronin-unhexdump.1.md) [ronin-unpack](ronin-unpack.1.md) [ronin-unquote](ronin-unquote.1.md) [ronin-url](ronin-url.1.md) [ronin-xor](ronin-xor.1.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
require 'spec_helper' | ||
require 'ronin/cli/commands/archive' | ||
require_relative 'man_page_example' | ||
|
||
describe Ronin::CLI::Commands::Archive do | ||
include_examples "man_page" | ||
end |