Repository: translate/pootle

Issue:
Some update_tmserver flags and feedback are confusing
I was trying the `update_tmserver` command and I found some confusing and counter-intuitive points:
1. Missing usage
   
   ``` bash
   $ ./manage.py update_tmserver
   CommandError: Specified Translation Memory is not defined in POOTLE_TM_SERVER.
   ```
   
   At this point the users are lost, as they didn't specify any TM yet it complains about the specified TM not being defined in `POOTLE_TM_SERVER`. At the same time, they have absolutely no clue what `POOTLE_TM_SERVER` is. Since this returns a `CommandError`, users might think they're doing something wrong when typing the command in, however the complain is about settings.
2. `--project` is ambiguous and confusing
   
   ```
   $ ./manage.py update_tmserver --tm=default foo.po
   CommandError: You must specify a project with --project.
   ```
   
   The naming is confusing, as one can think this has to be a project existing in Pootle, which is not the case. If it's a label or display name, let's rather use something along those lines, as `--project` is ambiguous in this context.
3. Incomplete usage message
   
   ```
   $ ./manage.py update_tmserver --help
   Usage: ./manage.py update_tmserver [options]
   ...
   ```
   
   Among other things, nowhere in the CLI is defined that one can pass file paths as arguments to the command.



Discussion:
Thanks a lot for your review.

> 1. Missing usage
> 
> ``` bash
> $ ./manage.py update_tmserver
> CommandError: Specified Translation Memory is not defined in POOTLE_TM_SERVER.
> ```
> 
> At this point the users are lost, as they didn't specify any TM yet it complains about the specified TM not being defined in `POOTLE_TM_SERVER`. At the same time, they have absolutely no clue what `POOTLE_TM_SERVER` is. Since this returns a `CommandError`, users might think they're doing something wrong when typing the command in, however the complain is about settings.

This happens because the user did not rename `default` TM server to `local`. Since `--tm` is not used, it defaults to `local`, but since that TM is missing on settings this error is thrown.

The message can be reworded like _CommandError: Translation Memory 'local' is missing in settings_. Will PR the change so people can give their opinion there.

> 1. `--project` is ambiguous and confusing
> 
> ```
> $ ./manage.py update_tmserver --tm=default foo.po
> CommandError: You must specify a project with --project.
> ```
> 
> The naming is confusing, as one can think this has to be a project existing in Pootle, which is not the case. If it's a label or display name, let's rather use something along those lines, as `--project` is ambiguous in this context.

I agree this might be confusing. Using `--display-name` or `--label` doesn't looks very self-explanatory, forcing users to check the help, so perhaps that is a better way. I am going to create a PR renaming it to `--display-name`.

> 1. Incomplete usage message
> 
> ```
> $ ./manage.py update_tmserver --help
> Usage: ./manage.py update_tmserver [options]
> ...
> ```
> 
> Among other things, nowhere in the CLI is defined that one can pass file paths as arguments to the command.

Yes, needs fixing. Tried to specify an `usage` variable in the command, but for some reason is failing.


Resolving patch:
diff --git a/pootle/apps/pootle_app/management/commands/update_tmserver.py b/pootle/apps/pootle_app/management/commands/update_tmserver.py
--- a/pootle/apps/pootle_app/management/commands/update_tmserver.py
+++ b/pootle/apps/pootle_app/management/commands/update_tmserver.py
@@ -150,6 +150,7 @@ def get_unit_data(self, unit):
 
 class Command(BaseCommand):
     help = "Load Translation Memory with translations"
+    args = "[files]"
     option_list = BaseCommand.option_list + (
         make_option('--refresh',
                     action='store_true',
@@ -181,11 +182,11 @@ class Command(BaseCommand):
                     default='',
                     help="Target language to fallback to use in case it can't "
                          "be guessed for any of the input files."),
-        make_option('--project',
+        make_option('--display-name',
                     action='store',
                     dest='project',
                     default='',
-                    help='Project to use when displaying TM matches for this '
+                    help='Name used when displaying TM matches for these '
                          'translations.'),
     )
 
@@ -221,8 +222,10 @@ def _initialize(self, *args, **options):
         try:
             self.tm_settings = settings.POOTLE_TM_SERVER[options.get('tm')]
         except KeyError:
-            raise CommandError('Specified Translation Memory is not defined '
-                               'in POOTLE_TM_SERVER.')
+            raise CommandError("Translation Memory '%s' is not defined in the "
+                               "POOTLE_TM_SERVER setting. Please ensure it "
+                               "exists and double-check you typed it "
+                               "correctly." % options.get('tm'))
 
         self.INDEX_NAME = self.tm_settings['INDEX_NAME']
         self.is_local_tm = options.get('tm') == 'local'


Test patch: