index.rst 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. ====
  2. mach
  3. ====
  4. Mach (German for *do*) is a generic command dispatcher for the command
  5. line.
  6. To use mach, you install the mach core (a Python package), create an
  7. executable *driver* script (named whatever you want), and write mach
  8. commands. When the *driver* is executed, mach dispatches to the
  9. requested command handler automatically.
  10. Features
  11. ========
  12. On a high level, mach is similar to using argparse with subparsers (for
  13. command handling). When you dig deeper, mach offers a number of
  14. additional features:
  15. Distributed command definitions
  16. With optparse/argparse, you have to define your commands on a central
  17. parser instance. With mach, you annotate your command methods with
  18. decorators and mach finds and dispatches to them automatically.
  19. Command categories
  20. Mach commands can be grouped into categories when displayed in help.
  21. This is currently not possible with argparse.
  22. Logging management
  23. Mach provides a facility for logging (both classical text and
  24. structured) that is available to any command handler.
  25. Settings files
  26. Mach provides a facility for reading settings from an ini-like file
  27. format.
  28. Components
  29. ==========
  30. Mach is conceptually composed of the following components:
  31. core
  32. The mach core is the core code powering mach. This is a Python package
  33. that contains all the business logic that makes mach work. The mach
  34. core is common to all mach deployments.
  35. commands
  36. These are what mach dispatches to. Commands are simply Python methods
  37. registered as command names. The set of commands is unique to the
  38. environment mach is deployed in.
  39. driver
  40. The *driver* is the entry-point to mach. It is simply an executable
  41. script that loads the mach core, tells it where commands can be found,
  42. then asks the mach core to handle the current request. The driver is
  43. unique to the deployed environment. But, it's usually based on an
  44. example from this source tree.
  45. Project State
  46. =============
  47. mach was originally written as a command dispatching framework to aid
  48. Firefox development. While the code is mostly generic, there are still
  49. some pieces that closely tie it to Mozilla/Firefox. The goal is for
  50. these to eventually be removed and replaced with generic features so
  51. mach is suitable for anybody to use. Until then, mach may not be the
  52. best fit for you.
  53. .. toctree::
  54. :maxdepth: 1
  55. commands
  56. driver
  57. logging
  58. settings