Skip to content

Commit

Permalink
Merge pull request #60 from rolobio/59-quiet-ssh
Browse files Browse the repository at this point in the history
Quieting SSH via -u command.
  • Loading branch information
rolobio committed Apr 6, 2015
2 parents 3efed7f + 2fa2936 commit 31baa15
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
6 changes: 6 additions & 0 deletions sshm/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ def get_argparse_args(args=None):
help='Disable command formatting.')
parser.add_argument('-q', '--quiet', action='store_true', default=False,
help='Hide server information on output. This implies sorted.')
parser.add_argument('-u', '--ssh-quiet', action='store_true', default=False,
help='Pass -q to the SSH command to quiet its output.')
parser.add_argument('--version', action='version', version='%(prog)s '+__version__)
args, extra_args = parser.parse_known_args(args=args)

Expand All @@ -64,6 +66,10 @@ def get_argparse_args(args=None):

if args.quiet:
args.sorted_output = True

# Pass -q to SSH command
if args.ssh_quiet:
extra_args.insert(0, '-q')
return (args, args.command, extra_args)


Expand Down
7 changes: 7 additions & 0 deletions sshm/test/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,13 @@ def test_get_argparse_args(self):
self.assertEqual(command, 'ls')
self.assertEqual(extra_args, [])

# You can quiet SSH (passing -q to ssh) by using -u
provided = ['example.com', 'command', '-o Something', '-u']
args, command, extra_args = get_argparse_args(provided)
self.assertEqual(args.servers, ['example.com',])
self.assertEqual(command, 'command')
self.assertEqual(extra_args, ['-q', '-o Something'])


def test__print_handling_newlines(self):
"""
Expand Down

0 comments on commit 31baa15

Please sign in to comment.