prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  CLI help usage is misleading
  Recommendation of usage in cli help message is misleading.
  
  **Steps:**
  ```
  datum -h
  ```
  **Expected result:**
  Correct form for usage recommendation
  
  **Current result:**
  ```
  usage: datumaro [-h] [--version] [--loglevel LOGLEVEL]
  ```
  ``` Run 'datumaro COMMAND --help```
  
  **Notes:**
  datumaro is not correct form, and results in "command not found". The same is command specific help messages. 
  
  
  </issue>
  <code>
  [start of datumaro/cli/__main__.py]
  1 
  2 # Copyright (C) 2019-2021 Intel Corporation
  3 #
  4 # SPDX-License-Identifier: MIT
  5 
  6 import argparse
  7 import logging as log
  8 import sys
  9 
  10 from . import contexts, commands
  11 from .util import CliException, add_subparser
  12 from ..version import VERSION
  13 
  14 
  15 _log_levels = {
  16     'debug': log.DEBUG,
  17     'info': log.INFO,
  18     'warning': log.WARNING,
  19     'error': log.ERROR,
  20     'critical': log.CRITICAL
  21 }
  22 
  23 def loglevel(name):
  24     return _log_levels[name]
  25 
  26 class _LogManager:
  27     @classmethod
  28     def init_logger(cls, args=None):
  29         # Define minimalistic parser only to obtain loglevel
  30         parser = argparse.ArgumentParser(add_help=False)
  31         cls._define_loglevel_option(parser)
  32         args, _ = parser.parse_known_args(args)
  33 
  34         log.basicConfig(format='%(asctime)s %(levelname)s: %(message)s',
  35             level=args.loglevel)
  36 
  37     @staticmethod
  38     def _define_loglevel_option(parser):
  39         parser.add_argument('--loglevel', type=loglevel, default='info',
  40             help="Logging level (options: %s; default: %s)" % \
  41                 (', '.join(_log_levels.keys()), "%(default)s"))
  42         return parser
  43 
  44 
  45 def _make_subcommands_help(commands, help_line_start=0):
  46     desc = ""
  47     for command_name, _, command_help in commands:
  48         desc += ("  %-" + str(max(0, help_line_start - 2 - 1)) + "s%s\n") % \
  49             (command_name, command_help)
  50     return desc
  51 
  52 def make_parser():
  53     parser = argparse.ArgumentParser(prog="datumaro",
  54         description="Dataset Framework",
  55         formatter_class=argparse.RawDescriptionHelpFormatter)
  56 
  57     parser.add_argument('--version', action='version', version=VERSION)
  58     _LogManager._define_loglevel_option(parser)
  59 
  60     known_contexts = [
  61         ('project', contexts.project, "Actions with project (deprecated)"),
  62         ('source', contexts.source, "Actions with data sources"),
  63         ('model', contexts.model, "Actions with models"),
  64     ]
  65     known_commands = [
  66         ('create', commands.create, "Create project"),
  67         ('import', commands.import_, "Create project from existing dataset"),
  68         ('add', commands.add, "Add data source to project"),
  69         ('remove', commands.remove, "Remove data source from project"),
  70         ('export', commands.export, "Export project in some format"),
  71         ('filter', commands.filter, "Filter project"),
  72         ('transform', commands.transform, "Transform project"),
  73         ('merge', commands.merge, "Merge projects"),
  74         ('convert', commands.convert, "Convert dataset into another format"),
  75         ('diff', commands.diff, "Compare projects with intersection"),
  76         ('ediff', commands.ediff, "Compare projects for equality"),
  77         ('stats', commands.stats, "Compute project statistics"),
  78         ('info', commands.info, "Print project info"),
  79         ('explain', commands.explain, "Run Explainable AI algorithm for model"),
  80         ('validate', commands.validate, "Validate project")
  81     ]
  82 
  83     # Argparse doesn't support subparser groups:
  84     # https://stackoverflow.com/questions/32017020/grouping-argparse-subparser-arguments
  85     help_line_start = max((len(e[0]) for e in known_contexts + known_commands),
  86         default=0)
  87     help_line_start = max((2 + help_line_start) // 4 + 1, 6) * 4 # align to tabs
  88     subcommands_desc = ""
  89     if known_contexts:
  90         subcommands_desc += "Contexts:\n"
  91         subcommands_desc += _make_subcommands_help(known_contexts,
  92             help_line_start)
  93     if known_commands:
  94         if subcommands_desc:
  95             subcommands_desc += "\n"
  96         subcommands_desc += "Commands:\n"
  97         subcommands_desc += _make_subcommands_help(known_commands,
  98             help_line_start)
  99     if subcommands_desc:
  100         subcommands_desc += \
  101             "\nRun '%s COMMAND --help' for more information on a command." % \
  102                 parser.prog
  103 
  104     subcommands = parser.add_subparsers(title=subcommands_desc,
  105         description="", help=argparse.SUPPRESS)
  106     for command_name, command, _ in known_contexts + known_commands:
  107         add_subparser(subcommands, command_name, command.build_parser)
  108 
  109     return parser
  110 
  111 
  112 def main(args=None):
  113     _LogManager.init_logger(args)
  114 
  115     parser = make_parser()
  116     args = parser.parse_args(args)
  117 
  118     if 'command' not in args:
  119         parser.print_help()
  120         return 1
  121 
  122     try:
  123         return args.command(args)
  124     except CliException as e:
  125         log.error(e)
  126         return 1
  127     except Exception as e:
  128         log.error(e)
  129         raise
  130 
  131 
  132 if __name__ == '__main__':
  133     sys.exit(main())
  [end of datumaro/cli/__main__.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/datumaro/cli/__main__.py b/datumaro/cli/__main__.py
  --- a/datumaro/cli/__main__.py
  +++ b/datumaro/cli/__main__.py
  @@ -5,6 +5,7 @@
   
   import argparse
   import logging as log
  +import os.path as osp
   import sys
   
   from . import contexts, commands
  @@ -50,9 +51,11 @@
       return desc
   
   def make_parser():
  -    parser = argparse.ArgumentParser(prog="datumaro",
  +    parser = argparse.ArgumentParser(
           description="Dataset Framework",
           formatter_class=argparse.RawDescriptionHelpFormatter)
  +    if parser.prog == osp.basename(__file__): # python -m datumaro ...
  +        parser.prog = 'datumaro'
   
       parser.add_argument('--version', action='version', version=VERSION)
       _LogManager._define_loglevel_option(parser)
  
verification_info: {"golden_diff": "diff --git a/datumaro/cli/__main__.py b/datumaro/cli/__main__.py\n--- a/datumaro/cli/__main__.py\n+++ b/datumaro/cli/__main__.py\n@@ -5,6 +5,7 @@\n \n import argparse\n import logging as log\n+import os.path as osp\n import sys\n \n from . import contexts, commands\n@@ -50,9 +51,11 @@\n     return desc\n \n def make_parser():\n-    parser = argparse.ArgumentParser(prog=\"datumaro\",\n+    parser = argparse.ArgumentParser(\n         description=\"Dataset Framework\",\n         formatter_class=argparse.RawDescriptionHelpFormatter)\n+    if parser.prog == osp.basename(__file__): # python -m datumaro ...\n+        parser.prog = 'datumaro'\n \n     parser.add_argument('--version', action='version', version=VERSION)\n     _LogManager._define_loglevel_option(parser)\n", "issue": "CLI help usage is misleading\nRecommendation of usage in cli help message is misleading.\r\n\r\n**Steps:**\r\n```\r\ndatum -h\r\n```\r\n**Expected result:**\r\nCorrect form for usage recommendation\r\n\r\n**Current result:**\r\n```\r\nusage: datumaro [-h] [--version] [--loglevel LOGLEVEL]\r\n```\r\n``` Run 'datumaro COMMAND --help```\r\n\r\n**Notes:**\r\ndatumaro is not correct form, and results in \"command not found\". The same is command specific help messages. \r\n\n", "before_files": [{"content": "\n# Copyright (C) 2019-2021 Intel Corporation\n#\n# SPDX-License-Identifier: MIT\n\nimport argparse\nimport logging as log\nimport sys\n\nfrom . import contexts, commands\nfrom .util import CliException, add_subparser\nfrom ..version import VERSION\n\n\n_log_levels = {\n    'debug': log.DEBUG,\n    'info': log.INFO,\n    'warning': log.WARNING,\n    'error': log.ERROR,\n    'critical': log.CRITICAL\n}\n\ndef loglevel(name):\n    return _log_levels[name]\n\nclass _LogManager:\n    @classmethod\n    def init_logger(cls, args=None):\n        # Define minimalistic parser only to obtain loglevel\n        parser = argparse.ArgumentParser(add_help=False)\n        cls._define_loglevel_option(parser)\n        args, _ = parser.parse_known_args(args)\n\n        log.basicConfig(format='%(asctime)s %(levelname)s: %(message)s',\n            level=args.loglevel)\n\n    @staticmethod\n    def _define_loglevel_option(parser):\n        parser.add_argument('--loglevel', type=loglevel, default='info',\n            help=\"Logging level (options: %s; default: %s)\" % \\\n                (', '.join(_log_levels.keys()), \"%(default)s\"))\n        return parser\n\n\ndef _make_subcommands_help(commands, help_line_start=0):\n    desc = \"\"\n    for command_name, _, command_help in commands:\n        desc += (\"  %-\" + str(max(0, help_line_start - 2 - 1)) + \"s%s\\n\") % \\\n            (command_name, command_help)\n    return desc\n\ndef make_parser():\n    parser = argparse.ArgumentParser(prog=\"datumaro\",\n        description=\"Dataset Framework\",\n        formatter_class=argparse.RawDescriptionHelpFormatter)\n\n    parser.add_argument('--version', action='version', version=VERSION)\n    _LogManager._define_loglevel_option(parser)\n\n    known_contexts = [\n        ('project', contexts.project, \"Actions with project (deprecated)\"),\n        ('source', contexts.source, \"Actions with data sources\"),\n        ('model', contexts.model, \"Actions with models\"),\n    ]\n    known_commands = [\n        ('create', commands.create, \"Create project\"),\n        ('import', commands.import_, \"Create project from existing dataset\"),\n        ('add', commands.add, \"Add data source to project\"),\n        ('remove', commands.remove, \"Remove data source from project\"),\n        ('export', commands.export, \"Export project in some format\"),\n        ('filter', commands.filter, \"Filter project\"),\n        ('transform', commands.transform, \"Transform project\"),\n        ('merge', commands.merge, \"Merge projects\"),\n        ('convert', commands.convert, \"Convert dataset into another format\"),\n        ('diff', commands.diff, \"Compare projects with intersection\"),\n        ('ediff', commands.ediff, \"Compare projects for equality\"),\n        ('stats', commands.stats, \"Compute project statistics\"),\n        ('info', commands.info, \"Print project info\"),\n        ('explain', commands.explain, \"Run Explainable AI algorithm for model\"),\n        ('validate', commands.validate, \"Validate project\")\n    ]\n\n    # Argparse doesn't support subparser groups:\n    # https://stackoverflow.com/questions/32017020/grouping-argparse-subparser-arguments\n    help_line_start = max((len(e[0]) for e in known_contexts + known_commands),\n        default=0)\n    help_line_start = max((2 + help_line_start) // 4 + 1, 6) * 4 # align to tabs\n    subcommands_desc = \"\"\n    if known_contexts:\n        subcommands_desc += \"Contexts:\\n\"\n        subcommands_desc += _make_subcommands_help(known_contexts,\n            help_line_start)\n    if known_commands:\n        if subcommands_desc:\n            subcommands_desc += \"\\n\"\n        subcommands_desc += \"Commands:\\n\"\n        subcommands_desc += _make_subcommands_help(known_commands,\n            help_line_start)\n    if subcommands_desc:\n        subcommands_desc += \\\n            \"\\nRun '%s COMMAND --help' for more information on a command.\" % \\\n                parser.prog\n\n    subcommands = parser.add_subparsers(title=subcommands_desc,\n        description=\"\", help=argparse.SUPPRESS)\n    for command_name, command, _ in known_contexts + known_commands:\n        add_subparser(subcommands, command_name, command.build_parser)\n\n    return parser\n\n\ndef main(args=None):\n    _LogManager.init_logger(args)\n\n    parser = make_parser()\n    args = parser.parse_args(args)\n\n    if 'command' not in args:\n        parser.print_help()\n        return 1\n\n    try:\n        return args.command(args)\n    except CliException as e:\n        log.error(e)\n        return 1\n    except Exception as e:\n        log.error(e)\n        raise\n\n\nif __name__ == '__main__':\n    sys.exit(main())", "path": "datumaro/cli/__main__.py"}]}