Skip to content

Commit

Permalink
Added the ronin-repos show command (closes #17).
Browse files Browse the repository at this point in the history
  • Loading branch information
postmodern committed May 10, 2023
1 parent 2c06fa8 commit 0de23c2
Show file tree
Hide file tree
Showing 6 changed files with 144 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -46,6 +46,7 @@ Commands:
new
purge
remove, rm
show, info
update, up
```

Expand Down
1 change: 1 addition & 0 deletions gemspec.yml
Expand Up @@ -23,6 +23,7 @@ generated_files:
- man/ronin-repos-list.1
- man/ronin-repos-new.1
- man/ronin-repos-remove.1
- man/ronin-repos-show.1
- man/ronin-repos-update.1
- man/ronin-repos-purge.1

Expand Down
7 changes: 4 additions & 3 deletions lib/ronin/repos/cli.rb
Expand Up @@ -41,9 +41,10 @@ class CLI
command_name 'ronin-repos'
version Ronin::Repos::VERSION

command_aliases['ls'] = 'list'
command_aliases['up'] = 'update'
command_aliases['rm'] = 'remove'
command_aliases['ls'] = 'list'
command_aliases['up'] = 'update'
command_aliases['rm'] = 'remove'
command_aliases['info'] = 'show'

end
end
Expand Down
93 changes: 93 additions & 0 deletions lib/ronin/repos/cli/commands/show.rb
@@ -0,0 +1,93 @@
# 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 <https://www.gnu.org/licenses/>.
#

require 'ronin/repos/cli/command'

require 'command_kit/printing/fields'
require 'command_kit/printing/lists'

module Ronin
module Repos
class CLI
module Commands
#
# Prints information about a specific repository in the cache directory.
#
# ## Usage
#
# ronin-repos show [options] REPO
#
# ## Options
#
# -C, --cache-dir DIR Overrides the default cache directory
# -h, --help Print help information
#
# ## Arguments
#
# REPO The repository to display
#
# @since 0.2.0
#
class Show < Command

include CommandKit::Printing::Fields
include CommandKit::Printing::Lists

usage '[options] [REPO]'

argument :name, required: true,
usage: 'REPO',
desc: 'The repository to display'

description 'Prints information about a repository in the cache directory'

man_page 'ronin-repos-show.1'

#
# Runs the `ronin-repos show` command.
#
# @param [String] name
# The repo name to display.
#
def run(name=nil)
repo = cache_dir[name]

puts "[ #{repo} ]"
puts

indent do
print_fields(
'Name' => repo.name,
'URI' => repo.url,
'Files' => nil
)

indent do
print_list(repo.list_files)
end
end
rescue RepositoryNotFound => error
print_error(error.message)
exit(-1)
end

end
end
end
end
end
2 changes: 1 addition & 1 deletion man/ronin-repos-list.1.md
Expand Up @@ -41,4 +41,4 @@ Postmodern <postmodern.mod3@gmail.com>

## SEE ALSO

ronin-repos(1) ronin-repos-install(1) ronin-repos-remove(1) ronin-repos-update(1) ronin-repos-purge(1)
ronin-repos(1) ronin-repos-install(1) ronin-repos-remove(1) ronin-repos-show(1) ronin-repos-update(1) ronin-repos-purge(1)
44 changes: 44 additions & 0 deletions man/ronin-repos-show.1.md
@@ -0,0 +1,44 @@
# ronin-repos-show 1 "2023-02-01" Ronin Repos "User Manuals"

## SYNOPSIS

`ronin-repos show` [*options*] *NAME*

## DESCRIPTION

Prints information about a specific repository in the cache directory.

## ARGUMENTS

*NAME*
The repository name to print information about.

## OPTIONS

`-C`, `--cache-dir` *DIR*
Overrides the default cache directory.

`-h`, `--help`
Prints help information.

## ENVIRONMENT

*HOME*
Specifies the home directory of the user. Ronin will search for the
`~/.cache/ronin-repos` cache directory within the home directory.

*XDG_CACHE_HOME*
Specifies the cache directory to use. Defaults to `$HOME/.cache`.

## FILES

`~/.cache/ronin-repos`
Installation directory for repositories.

## AUTHOR

Postmodern <postmodern.mod3@gmail.com>

## SEE ALSO

ronin-repos(1) ronin-repos-list(1) ronin-repos-install(1) ronin-repos-remove(1) ronin-repos-update(1) ronin-repos-purge(1)

0 comments on commit 0de23c2

Please sign in to comment.