Print meaningul error when invalid target specified and exit

Also adjust test_help accordingly.

Change-Id: Ib209e60937599604cdc60d06199a967aeab8ea11
Fixes-bug: #1309097
This commit is contained in:
Noorul Islam K M
2014-04-18 21:04:10 +05:30
parent 5ec4a86f96
commit 70eedf71c7
2 changed files with 8 additions and 8 deletions

View File

@@ -216,9 +216,10 @@ def main():
try:
parsed, _ = parser.parse_known_args()
resource = parsed.resource
except Exception as se_except:
except Exception:
print("Invalid target specified to act upon.\n")
parser.print_help()
return se_except
sys.exit(1)
if resource in resources:
try:

View File

@@ -95,12 +95,11 @@ class TestSolum(base.TestCase):
'.*?^optional arguments'
]
for argstr in ['--help', 'help']:
help_text = self.shell(argstr)
for r in required:
self.assertThat(help_text,
matchers.MatchesRegex(r,
self.re_options))
help_text = self.shell('--help')
for r in required:
self.assertThat(help_text,
matchers.MatchesRegex(r,
self.re_options))
# Assembly Tests #
@mock.patch.object(assembly.AssemblyManager, "list")