From 07e74111551ebf3b54c481bbd3ab0d27f93d1501 Mon Sep 17 00:00:00 2001 From: Maxim Beiner Date: Tue, 28 Mar 2017 11:14:14 +0600 Subject: [PATCH] Improve grammar of the messages. --- .prospector.yaml | 3 +++ dev-requirements.txt | 3 ++- termius/account/commands.py | 14 +++++++------- termius/app.py | 6 +++--- termius/cloud/commands.py | 6 +++--- termius/core/commands/base.py | 2 +- termius/core/commands/help.py | 2 +- termius/core/commands/mixins.py | 4 ++-- termius/core/commands/single.py | 4 ++-- termius/handlers/connect.py | 8 ++++---- termius/handlers/group.py | 9 +++++---- termius/handlers/host.py | 21 +++++++++++---------- termius/handlers/identity.py | 12 ++++++------ termius/handlers/info.py | 8 ++++++-- termius/handlers/init.py | 2 +- termius/handlers/pf_rule.py | 10 +++++----- termius/handlers/snippet.py | 4 ++-- termius/handlers/ssh_config.py | 28 ++++++++++++++-------------- termius/handlers/ssh_key.py | 4 ++-- termius/handlers/tag.py | 8 ++++---- termius/porting/commands.py | 8 ++++---- 21 files changed, 88 insertions(+), 78 deletions(-) diff --git a/.prospector.yaml b/.prospector.yaml index cddc887..f31970d 100644 --- a/.prospector.yaml +++ b/.prospector.yaml @@ -9,6 +9,8 @@ ignore-paths: - build - tests - termius/core/utils.py # it's too complex + - termius/core/commands/help.py # it's too complex + ignore-patterns: - (^|/)(?!termius)?(/|$) @@ -17,6 +19,7 @@ pep257: disable: - D203 # 1 blank line required before - D213 + - D400 pylint: options: diff --git a/dev-requirements.txt b/dev-requirements.txt index fd7e11d..7d49078 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -1,7 +1,8 @@ mock nose coverage -prospector[with_pyroma] +prospector[with_pyroma]==0.12.4 +pylint==1.6.5 pyroma==2.0 paver bumpversion diff --git a/termius/account/commands.py b/termius/account/commands.py index dd267ff..48b4ef8 100644 --- a/termius/account/commands.py +++ b/termius/account/commands.py @@ -21,12 +21,12 @@ def __init__(self, app, app_args, cmd_name=None): class LoginCommand(BaseAccountCommand): - """sign into Termius Cloud""" + """sign into the Termius Cloud""" # pylint: disable=no-self-use def prompt_username(self): """Ask username prompt.""" - return six.moves.input("Username: ") + return six.moves.input('Username: ') # pylint: disable=no-self-use def prompt_authy_token(self): @@ -53,7 +53,7 @@ def take_action(self, parsed_args): class LogoutCommand(BaseAccountCommand): - """sign out Termius Cloud""" + """sign out of the Termius Cloud""" def take_action(self, _): """Process CLI call.""" @@ -63,19 +63,19 @@ def take_action(self, _): class SettingsCommand(BaseAccountCommand): - """update account settings""" + """update the account settings""" def extend_parser(self, parser): """Add more arguments to parser.""" parser.add_argument( '--synchronize-key', action='store', type=boolean_yes_no, choices=(False, True), default=True, - help='Sync ssh keys and ssh identities or not.' + help='enable/disable ssh keys and identities sync' ) parser.add_argument( '--agent-forwarding', action='store', type=boolean_yes_no, choices=(False, True), default=True, - help='Sync ssh keys and ssh identities or not.' + help='enable/disable agent forwarding' ) return parser @@ -86,7 +86,7 @@ def take_action(self, args): for k in ('synchronize_key', 'agent_forwarding') } self.manager.set_settings(settings) - self.log.info('Set settings.') + self.log.info('Settings updated') @contextmanager diff --git a/termius/app.py b/termius/app.py index a9e5165..acbcc78 100644 --- a/termius/app.py +++ b/termius/app.py @@ -113,13 +113,13 @@ def build_option_parser(self, description, version, action='store_const', dest='verbose_level', const=0, - help='only display warnings and errors', + help='display warnings and errors only', ) parser.add_argument( '--log-file', action='store', default=None, - help='record output in a designated file', + help='record output into a designated file', ) if self.deferred_help: parser.add_argument( @@ -134,7 +134,7 @@ def build_option_parser(self, description, version, action=HelpAction, nargs=0, default=self, # tricky - help="display help message", + help="show the help message", ) parser.add_argument( '--debug', diff --git a/termius/cloud/commands.py b/termius/cloud/commands.py index 818b2f4..63461be 100644 --- a/termius/cloud/commands.py +++ b/termius/cloud/commands.py @@ -49,7 +49,7 @@ def validate_password(self, password): class PushCommand(CloudSynchronizationCommand): - """push data to Termius Cloud""" + """push data to the Termius Cloud""" get_strategy = RelatedGetStrategy save_strategy = SyncSaveStrategy @@ -66,7 +66,7 @@ def process_sync(self, api_controller): class PullCommand(CloudSynchronizationCommand): - """pull data from Termius Cloud""" + """pull data from the Termius Cloud""" save_strategy = SyncSaveStrategy @@ -78,7 +78,7 @@ def process_sync(self, api_controller): class FullCleanCommand(CloudSynchronizationCommand): - """remove user data from Termius Cloud""" + """remove user data from the Termius Cloud""" get_strategy = RelatedGetStrategy save_strategy = SyncSaveStrategy diff --git a/termius/core/commands/base.py b/termius/core/commands/base.py index 66bb44b..f766a5e 100644 --- a/termius/core/commands/base.py +++ b/termius/core/commands/base.py @@ -39,7 +39,7 @@ def get_parser(self, prog_name): """Create command line argument parser.""" parser = super(AbstractCommand, self).get_parser(prog_name) parser.add_argument( - '--log-file', help='record output in a designated file' + '--log-file', help='record output to FILE' ) return self.extend_parser(parser) diff --git a/termius/core/commands/help.py b/termius/core/commands/help.py index 8e463ec..1b5bf1c 100644 --- a/termius/core/commands/help.py +++ b/termius/core/commands/help.py @@ -43,7 +43,7 @@ def __call__(self, parser, namespace, values, option_string=None): class HelpCommand(BaseHelpCommand): - """display command specific help message""" + """display the command specific help message""" def take_action(self, parsed_args): if parsed_args.cmd: diff --git a/termius/core/commands/mixins.py b/termius/core/commands/mixins.py index b1c7cbf..9d6d9df 100644 --- a/termius/core/commands/mixins.py +++ b/termius/core/commands/mixins.py @@ -44,14 +44,14 @@ def get_relation(self, model_class, arg): def fail_not_exist(self, model_class): """Raise an error about not existed instance.""" raise ArgumentRequiredException( - 'Not found any {} instance.'.format(model_class) + 'Not found any {} instance.'.format(model_class.__name__.lower()) ) # pylint: disable=no-self-use def fail_too_many(self, model_class): """Raise an error about too many instances.""" raise ArgumentRequiredException( - 'Found too many {} instances.'.format(model_class) + 'Found too many {} instances.'.format(model_class.__name__.lower()) ) def get_safely_instance(self, model_class, arg): diff --git a/termius/core/commands/single.py b/termius/core/commands/single.py index b0b221b..3cab0fb 100644 --- a/termius/core/commands/single.py +++ b/termius/core/commands/single.py @@ -63,11 +63,11 @@ def get_parser(self, prog_name): ) parser.add_argument( '-L', '--label', metavar='NAME', - help="entry label" + help="name or rename the entry label NAME" ) parser.add_argument( 'entry', nargs='*', metavar='ID or NAME', - help='pass to edit existed entries' + help='select the entry with ID or NAME' ) return parser diff --git a/termius/handlers/connect.py b/termius/handlers/connect.py index 8da009a..b98dfbe 100644 --- a/termius/handlers/connect.py +++ b/termius/handlers/connect.py @@ -11,7 +11,7 @@ class ConnectCommand(SshCommandFormatterMixin, SshConfigMergerMixin, GetRelationMixin, AbstractCommand): - """connect to specific host""" + """connect to a specific host with NAME or ID""" get_strategy = RelatedGetStrategy @@ -20,16 +20,16 @@ def extend_parser(self, parser): parser.add_argument( '-H', '--host', const=Host, dest='model', action='store_const', default=Host, - help='connect to host or start portforwarding rule' + help='connect to a host' ) parser.add_argument( '-R', '--pfrule', const=PFRule, dest='model', action='store_const', default=Host, - help='connect to host or start portforwarding rule' + help='connect to a host using a port forwarding rule' ) parser.add_argument( 'entry', metavar='ID or NAME', - help='connect to host or start portforwarding rule' + help='connect to the specific host' ) return parser diff --git a/termius/handlers/group.py b/termius/handlers/group.py index a03a5d5..7bcb6cf 100644 --- a/termius/handlers/group.py +++ b/termius/handlers/group.py @@ -12,7 +12,7 @@ class GroupCommand(GroupStackGetterMixin, DetailCommand): - """operate with group object""" + """work with a group""" model_class = Group @@ -37,7 +37,8 @@ def extend_parser(self, parser): """Add more arguments to parser.""" parser.add_argument( '-g', '--parent-group', - metavar='PARENT_GROUP', help="parent group id or name" + metavar='PARENT_GROUP', + help='select the parent group with ID or NAME' ) self.ssh_config_args.add_agrs(parser) return parser @@ -63,7 +64,7 @@ def serialize_args(self, args, instance=None): class GroupsCommand(SshConfigPrepareMixin, ListCommand): - """list group objects""" + """list all groups""" model_class = Group get_strategy = RelatedGetStrategy @@ -77,7 +78,7 @@ def extend_parser(self, parser): ) parser.add_argument( 'group', nargs='?', metavar='GROUP_ID or GROUP_NAME', - help='list groups in this group' + help='list groups in the group with ID or NAME' ) return parser diff --git a/termius/handlers/host.py b/termius/handlers/host.py index 7cf6fb9..82af93c 100644 --- a/termius/handlers/host.py +++ b/termius/handlers/host.py @@ -12,7 +12,7 @@ class HostCommand(DetailCommand): - """operate with host object""" + """work with a host""" model_class = Host required_options = RequiredOptions(create=('address',)) @@ -35,13 +35,13 @@ def __init__(self, app, app_args, cmd_name=None): def extend_parser(self, parser): """Add more arguments to parser.""" parser.add_argument( - '-t', '--tag', metavar='TAG_NAME', + '-t', '--tag', metavar='TAG', action='append', default=[], dest='tags', - help='specify the tag(s) for host, can be repeated' + help='specify the TAG(s) for a host (can be repeated)' ) parser.add_argument( - '-g', '--group', metavar='GROUP_ID or GROUP_NAME', - help='move hosts to this group' + '-g', '--group', metavar='ID or NAME', + help='move the host to the group with ID or NAME' ) parser.add_argument( '-a', '--address', @@ -76,7 +76,7 @@ def serialize_args(self, args, instance=None): class HostsCommand(GroupStackGetterMixin, ListCommand): - """list host objects""" + """list all hosts""" model_class = Host get_strategy = RelatedGetStrategy @@ -89,13 +89,14 @@ def __init__(self, app, app_args, cmd_name=None): def extend_parser(self, parser): """Add more arguments to parser.""" parser.add_argument( - '-t', '--tag', metavar='TAG_NAME', + '-t', '--tag', metavar='TAG', action='append', default=[], dest='tags', - help='specify the tag(s) for host, can be repeated' + help='specify the TAG(s) for a host (can be repeated)' ) parser.add_argument( - '-g', '--group', metavar='GROUP_ID or GROUP_NAME', - help=('list hosts in group (current group by default)') + '-g', '--group', metavar='ID or NAME', + help=('list hosts in the group with ID or NAME' + '(current group by default)') ) return parser diff --git a/termius/handlers/identity.py b/termius/handlers/identity.py index e5013e7..01e3eea 100644 --- a/termius/handlers/identity.py +++ b/termius/handlers/identity.py @@ -10,7 +10,7 @@ class IdentityCommand(SshKeyGeneratorMixin, DetailCommand): - """operate with identity object""" + """work with an identity""" model_class = Identity @@ -42,19 +42,19 @@ def extend_parser(self, parser): """Add more arguments to parser.""" parser.add_argument( '-u', '--username', - metavar='USERNAME', help="username for SSH authorization" + metavar='USERNAME', help='username for ssh authentication' ) parser.add_argument( '-p', '--password', - metavar='PASSWORD', help="password for SSH authorization" + metavar='PASSWORD', help='password for ssh authentication' ) parser.add_argument( '-i', '--identity-file', - metavar='PRIVATE_KEY', help='private key' + metavar='FILE', help='select FILE as private key' ) parser.add_argument( '-k', '--ssh-key', - metavar='SSH_KEY', help="ssh key name or id" + metavar='ID or NAME', help='define ssh key with ID or NAME' ) return parser @@ -71,7 +71,7 @@ def get_objects(self, ids__names): class IdentitiesCommand(ListCommand): - """list identity objects""" + """list all identities""" model_class = Identity diff --git a/termius/handlers/info.py b/termius/handlers/info.py index 88d96ca..d0b736f 100644 --- a/termius/handlers/info.py +++ b/termius/handlers/info.py @@ -12,7 +12,7 @@ class InfoCommand(SshConfigMergerMixin, GetRelationMixin, ShowOne, AbstractCommand): - """display info about host or group""" + """display info about a host or group""" get_strategy = RelatedGetStrategy model_class = SshConfig @@ -38,7 +38,11 @@ def extend_parser(self, parser): '-M', '--no-merge', action='store_true', help='do not merge configs' ) - parser.add_argument('id_or_name', metavar='ID or NAME') + parser.add_argument( + 'id_or_name', + metavar='ID or NAME', + help='display information about the group or host with ID' + ) return parser # pylint: disable=unused-argument diff --git a/termius/handlers/init.py b/termius/handlers/init.py index ad1f58c..40954a0 100644 --- a/termius/handlers/init.py +++ b/termius/handlers/init.py @@ -12,7 +12,7 @@ class InitCommand(AbstractCommand): - """initialize Termius CLI""" + """initialize the Termius CLI""" # pylint: disable=no-self-use def prompt_username(self): diff --git a/termius/handlers/pf_rule.py b/termius/handlers/pf_rule.py index 64a1154..d56963d 100644 --- a/termius/handlers/pf_rule.py +++ b/termius/handlers/pf_rule.py @@ -10,7 +10,7 @@ class PFRuleCommand(DetailCommand): - """operate with port forwarding rule object""" + """work with a port forwarding rule""" model_class = PFRule required_options = RequiredOptions(create=('host', 'binding', 'pf_type')) @@ -37,8 +37,8 @@ def binding_parsers(self): def extend_parser(self, parser): """Add more arguments to parser.""" parser.add_argument( - '-H', '--host', metavar='HOST_ID or HOST_NAME', - help='create port forwarding rule for this host' + '-H', '--host', metavar='ID or NAME', + help='create port forwarding rule for the host with ID or NAME' ) parser.add_argument( '--dynamic', dest='pf_type', action='store_const', @@ -53,7 +53,7 @@ def extend_parser(self, parser): const='L', help='local port forwarding' ) parser.add_argument( - '--binding', metavar='BINDINDS', + '--binding', metavar='BINDINGS', help=('specify binding of ports and addresses ' '[bind_address:]port or [bind_address:]port:host:hostport') ) @@ -74,7 +74,7 @@ def serialize_args(self, args, instance=None): class PFRulesCommand(ListCommand): - """list port forwarding rule objects""" + """list all port forwarding rules""" model_class = PFRule diff --git a/termius/handlers/snippet.py b/termius/handlers/snippet.py index cf1cc13..4301b2d 100644 --- a/termius/handlers/snippet.py +++ b/termius/handlers/snippet.py @@ -6,7 +6,7 @@ class SnippetCommand(DetailCommand): - """operate with snippet object""" + """work with snippet""" model_class = Snippet required_options = RequiredOptions(create=('script',)) @@ -21,6 +21,6 @@ def extend_parser(self, parser): class SnippetsCommand(ListCommand): - """list snippet objects""" + """list all snippets""" model_class = Snippet diff --git a/termius/handlers/ssh_config.py b/termius/handlers/ssh_config.py index 1d73c6f..77d1e94 100644 --- a/termius/handlers/ssh_config.py +++ b/termius/handlers/ssh_config.py @@ -38,16 +38,16 @@ def get_ssh_key_field(self, args): def add_args(self, parser): """Add identity args to argparser.""" parser.add_argument( - '-u', '--username', metavar='SSH_USERNAME', - help='username for SSH authorization' + '-u', '--username', metavar='USERNAME', + help='USERNAME for ssh authentication' ) parser.add_argument( - '-P', '--password', metavar='SSH_PASSWORD', - help='password for SSH authorization' + '-P', '--password', metavar='PASSWORD', + help='PASSWORD for ssh authentication' ) parser.add_argument( - '-i', '--identity-file', metavar='IDENTITY_FILE', - help=('select the private key file') + '-i', '--identity-file', metavar='FILE', + help=('select FILE as private key') ) return parser @@ -82,35 +82,35 @@ def add_agrs(self, parser): parser.add_argument( '-p', '--port', type=int, metavar='PORT', - help='ssh port' + help='assign PORT to ssh config' ) parser.add_argument( - '-s', '--snippet', metavar='SNIPPET_ID or SNIPPET_NAME', - help='snippet id or snippet name' + '-s', '--snippet', metavar='SNIPPET', + help='assign SNIPPET to ssh config' ) parser.add_argument( '--identity', - metavar='IDENTITY', help="identity id or name" + metavar='IDENTITY', help="assign IDENTITY to ssh config" ) parser.add_argument( '-S', '--strict-host-key-check', type=str, choices=('yes', 'no'), - help='enable/disable to force check ssh server public key' + help='check host public key by force (enable/disable)' ) parser.add_argument( '--use-ssh-key', type=str, choices=('yes', 'no'), - help='enable/disable to force ssh key use' + help='use public key by force (enable/disable)' ) parser.add_argument( '-k', '--keep-alive-packages', type=int, metavar='PACKAGES_COUNT', - help='ServerAliveCountMax option from ssh_config' + help='define ServerAliveCountMax in the ssh config' ) parser.add_argument( '-T', '--timeout', type=int, metavar='SECONDS', - help='ServerAliveInterval option from ssh_config' + help='define ServerAliveInterval in the ssh config' ) self.identity_args.add_args(parser) diff --git a/termius/handlers/ssh_key.py b/termius/handlers/ssh_key.py index 4b67d7e..3efbb61 100644 --- a/termius/handlers/ssh_key.py +++ b/termius/handlers/ssh_key.py @@ -34,7 +34,7 @@ def validate_ssh_key(self, instance): class SshKeyCommand(SshKeyGeneratorMixin, DetailCommand): - """operate with Host object""" + """work with an ssh key""" model_class = SshKey required_options = RequiredOptions(create=('identity_file', 'label')) @@ -67,6 +67,6 @@ def validate(self, instance): class SshKeysCommand(ListCommand): - """list ssh key objects""" + """list all ssh keys""" model_class = SshKey diff --git a/termius/handlers/tag.py b/termius/handlers/tag.py index 9abc199..62ab310 100644 --- a/termius/handlers/tag.py +++ b/termius/handlers/tag.py @@ -6,7 +6,7 @@ class TagsCommand(GetObjectsMixin, InstanceOperationMixin, ListCommand): - """list tag objects""" + """list all tags""" model_class = Tag @@ -14,11 +14,11 @@ def extend_parser(self, parser): """Add more arguments to parser.""" parser.add_argument( '-d', '--delete', - action='store_true', help='delete tags' + action='store_true', help='delete the selected tags' ) parser.add_argument( - 'tags', nargs='*', metavar='TAG_ID or TAG_NAME', - help='list info about this tags' + 'tags', nargs='*', metavar='ID or NAME', + help='select the tag with ID or NAME and list info' ) return parser diff --git a/termius/porting/commands.py b/termius/porting/commands.py index 145b491..b1ba414 100644 --- a/termius/porting/commands.py +++ b/termius/porting/commands.py @@ -10,7 +10,7 @@ class SSHImportCommand(AbstractCommand): - """import hosts from user`s ssh config""" + """import the local ssh config file""" save_strategy = RelatedSaveStrategy get_strategy = RelatedGetStrategy @@ -27,16 +27,16 @@ def take_action(self, parsed_args): ) self.log.info( - '\nImport completed, part of the hosts was ignored.' + '\nImport completed, part of the hosts was ignored' ) else: self.log.info( - 'Import hosts from ~/.ssh/config to local storage.' + 'Import hosts from ~/.ssh/config to local storage' ) class SSHExportCommand(AbstractCommand): - """export hosts from local storage to file""" + """export hosts from the local storage to a file""" get_strategy = RelatedGetStrategy