Skip to content

Commit

Permalink
Auto merge of #28648 - jdm:mach-vendor, r=jdm
Browse files Browse the repository at this point in the history
Vendor mach-1.0.0.

This will allow us to fork the package and make the changes necessary to solve #28631.
  • Loading branch information
bors-servo committed Dec 21, 2021
2 parents 8dc59c6 + f4de057 commit 708bf2f
Show file tree
Hide file tree
Showing 24 changed files with 2,850 additions and 1 deletion.
29 changes: 29 additions & 0 deletions python/mach/PKG-INFO
@@ -0,0 +1,29 @@
Metadata-Version: 1.1
Name: mach
Version: 1.0.0
Summary: Generic command line command dispatching framework.
Home-page: https://developer.mozilla.org/en-US/docs/Developer_Guide/mach
Author: Gregory Szorc
Author-email: gregory.szorc@gmail.com
License: MPL 2.0
Description: ====
mach
====

Mach (German for *do*) is a generic command dispatcher for the command
line.

To use mach, you install the mach core (a Python package), create an
executable *driver* script (named whatever you want), and write mach
commands. When the *driver* is executed, mach dispatches to the
requested command handler automatically.

To learn more, read the docs in ``docs/``.

Platform: UNKNOWN
Classifier: Environment :: Console
Classifier: Development Status :: 5 - Production/Stable
Classifier: License :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)
Classifier: Natural Language :: English
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3.5
13 changes: 13 additions & 0 deletions python/mach/README.rst
@@ -0,0 +1,13 @@
====
mach
====

Mach (German for *do*) is a generic command dispatcher for the command
line.

To use mach, you install the mach core (a Python package), create an
executable *driver* script (named whatever you want), and write mach
commands. When the *driver* is executed, mach dispatches to the
requested command handler automatically.

To learn more, read the docs in ``docs/``.
29 changes: 29 additions & 0 deletions python/mach/mach.egg-info/PKG-INFO
@@ -0,0 +1,29 @@
Metadata-Version: 1.1
Name: mach
Version: 1.0.1
Summary: Generic command line command dispatching framework.
Home-page: https://developer.mozilla.org/en-US/docs/Developer_Guide/mach
Author: Gregory Szorc
Author-email: gregory.szorc@gmail.com
License: MPL 2.0
Description: ====
mach
====

Mach (German for *do*) is a generic command dispatcher for the command
line.

To use mach, you install the mach core (a Python package), create an
executable *driver* script (named whatever you want), and write mach
commands. When the *driver* is executed, mach dispatches to the
requested command handler automatically.

To learn more, read the docs in ``docs/``.

Platform: UNKNOWN
Classifier: Environment :: Console
Classifier: Development Status :: 5 - Production/Stable
Classifier: License :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)
Classifier: Natural Language :: English
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3.5
21 changes: 21 additions & 0 deletions python/mach/mach.egg-info/SOURCES.txt
@@ -0,0 +1,21 @@
README.rst
setup.cfg
setup.py
mach/__init__.py
mach/base.py
mach/config.py
mach/decorators.py
mach/dispatcher.py
mach/logging.py
mach/main.py
mach/registrar.py
mach/terminal.py
mach/util.py
mach.egg-info/PKG-INFO
mach.egg-info/SOURCES.txt
mach.egg-info/dependency_links.txt
mach.egg-info/requires.txt
mach.egg-info/top_level.txt
mach/mixin/__init__.py
mach/mixin/logging.py
mach/mixin/process.py
1 change: 1 addition & 0 deletions python/mach/mach.egg-info/dependency_links.txt
@@ -0,0 +1 @@

4 changes: 4 additions & 0 deletions python/mach/mach.egg-info/requires.txt
@@ -0,0 +1,4 @@
blessings
mozfile
mozprocess
six
1 change: 1 addition & 0 deletions python/mach/mach.egg-info/top_level.txt
@@ -0,0 +1 @@
mach
Empty file added python/mach/mach/__init__.py
Empty file.
66 changes: 66 additions & 0 deletions python/mach/mach/base.py
@@ -0,0 +1,66 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

from __future__ import absolute_import, unicode_literals


class CommandContext(object):
"""Holds run-time state so it can easily be passed to command providers."""
def __init__(self, cwd=None, settings=None, log_manager=None, commands=None, **kwargs):
self.cwd = cwd
self.settings = settings
self.log_manager = log_manager
self.commands = commands
self.command_attrs = {}

for k, v in kwargs.items():
setattr(self, k, v)


class MachError(Exception):
"""Base class for all errors raised by mach itself."""


class NoCommandError(MachError):
"""No command was passed into mach."""


class UnknownCommandError(MachError):
"""Raised when we attempted to execute an unknown command."""

def __init__(self, command, verb, suggested_commands=None):
MachError.__init__(self)

self.command = command
self.verb = verb
self.suggested_commands = suggested_commands or []


class UnrecognizedArgumentError(MachError):
"""Raised when an unknown argument is passed to mach."""

def __init__(self, command, arguments):
MachError.__init__(self)

self.command = command
self.arguments = arguments


class FailedCommandError(Exception):
"""Raised by commands to signal a handled failure to be printed by mach
When caught by mach a FailedCommandError will print message and exit
with ''exit_code''. The optional ''reason'' is a string in cases where
other scripts may wish to handle the exception, though this is generally
intended to communicate failure to mach.
"""

def __init__(self, message, exit_code=1, reason=''):
Exception.__init__(self, message)
self.exit_code = exit_code
self.reason = reason


class MissingFileError(MachError):
"""Attempted to load a mach commands file that doesn't exist."""

0 comments on commit 708bf2f

Please sign in to comment.