mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
3161a91d7e
* Implement a framework for having common code for release scripts * Release scripts will go through hacking/build-ansible. build-ansible is a pluggable script which will set a directory that has common code for non-enduser scripts. It will then invoke the plugin which implements that subcommand. Uses straight.plugin for loading each sub-command. * We're going to add tools which are needed to test ansible (the changelog generation, for instance) so we need to include the pieces relevant to that in the tarball. * Add straight.plugin to the sanity test requirements for the same reason * Skip compile test just for build-ansible plugins which won't be run as part of sanity tests.
50 lines
1.5 KiB
Python
50 lines
1.5 KiB
Python
# coding: utf-8
|
|
# Copyright: (c) 2019, Ansible Project
|
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
|
|
|
# Make coding more python3-ish
|
|
from __future__ import (absolute_import, division, print_function)
|
|
__metaclass__ = type
|
|
|
|
|
|
from abc import ABCMeta, abstractmethod, abstractproperty
|
|
|
|
|
|
class Command:
|
|
"""
|
|
Subcommands of :program:`build-ansible`.
|
|
|
|
This defines an interface that all subcommands must conform to. :program:`build-ansible` will
|
|
require that these things are present in order to proceed.
|
|
"""
|
|
@staticmethod
|
|
@abstractproperty
|
|
def name():
|
|
"""Name of the command. The same as the string is invoked with"""
|
|
|
|
@staticmethod
|
|
@abstractmethod
|
|
def init_parser(add_parser):
|
|
"""
|
|
Initialize and register an argparse ArgumentParser
|
|
|
|
:arg add_parser: function which creates an ArgumentParser for the main program.
|
|
|
|
Implementations should first create an ArgumentParser using `add_parser` and then populate
|
|
it with the command line arguments that are needed.
|
|
|
|
.. seealso:
|
|
`add_parser` information in the :py:meth:`ArgumentParser.add_subparsers` documentation.
|
|
"""
|
|
|
|
@staticmethod
|
|
@abstractmethod
|
|
def main(arguments):
|
|
"""
|
|
Run the command
|
|
|
|
:arg arguments: The **parsed** command line args
|
|
|
|
This is the Command's entrypoint. The command line args are already parsed but from here
|
|
on, the command can do its work.
|
|
"""
|