Move Rex::Text::Table workspace output to -v

bug/bundler_fix
William Vu 2017-01-15 23:15:14 -06:00
parent 83ef454430
commit 77c78fa5f4
2 changed files with 36 additions and 3 deletions

View File

@ -86,6 +86,7 @@ class Db
def cmd_workspace_help
print_line "Usage:"
print_line " workspace List workspaces"
print_line " workspace -v List workspaces verbosely"
print_line " workspace [name] Switch workspace"
print_line " workspace -a [name] ... Add workspace(s)"
print_line " workspace -d [name] ... Delete workspace(s)"
@ -111,6 +112,8 @@ class Db
delete_all = true
when '-r','--rename'
renaming = true
when '-v'
verbose = true
else
names ||= []
names << arg
@ -178,12 +181,21 @@ class Db
end
else
workspace = framework.db.workspace
unless verbose
framework.db.workspaces.each do |ws|
pad = (ws == workspace) ? '* ' : ' '
print_line("#{pad}#{ws.name}")
end
return
end
col_names = %w{current name hosts services vulns creds loots notes}
tbl = Rex::Text::Table.new(
'Header' => 'Workspaces',
'Columns' => col_names,
'SortIndex' => 1
'SortIndex' => -1
)
# List workspaces

View File

@ -542,9 +542,29 @@ RSpec.describe Msf::Ui::Console::CommandDispatcher::Db do
db.cmd_workspace "-D"
@output = []
end
describe "<no arguments>" do
it "should list default workspace" do
db.cmd_workspace
expect(@output).to match_array [
"* default"
]
end
it "should list all workspaces" do
db.cmd_workspace("-a", "foo")
@output = []
db.cmd_workspace
expect(@output).to match_array [
" default",
"* foo"
]
end
end
describe "-v" do
it "should list default workspace verbosely" do
db.cmd_workspace("-v")
expect(@output).to match_array [
"",
"Workspaces",
@ -555,10 +575,10 @@ RSpec.describe Msf::Ui::Console::CommandDispatcher::Db do
]
end
it "should list all workspaces" do
it "should list all workspaces verbosely" do
db.cmd_workspace("-a", "foo")
@output = []
db.cmd_workspace
db.cmd_workspace("-v")
expect(@output).to match_array [
"",
"Workspaces",
@ -613,6 +633,7 @@ RSpec.describe Msf::Ui::Console::CommandDispatcher::Db do
expect(@output).to match_array [
"Usage:",
" workspace List workspaces",
" workspace -v List workspaces verbosely",
" workspace [name] Switch workspace",
" workspace -a [name] ... Add workspace(s)",
" workspace -d [name] ... Delete workspace(s)",