Commit f4fc79aa authored by Samuel GAIST's avatar Samuel GAIST
Browse files

[click_helper] Added AssetCommand and AssetInfo clases

These classes will allow to more cleanly provide asset
information through the chain of commands.
parent 29317319
......@@ -79,3 +79,34 @@ class MutuallyExclusiveOption(click.Option):
return super().handle_parse_result(ctx, opts, args)
class AssetInfo:
""" Information needed by the command to properly call local and remote
def __init__(
self, asset_type=None, diff_fields=None, push_fields=None, get_dependencies=None
self.asset_type = asset_type
self.diff_fields = diff_fields
self.push_fields = push_fields
self.get_dependencies = get_dependencies
def __repr__(self):
return "{}\n{}\n{}\n{}".format(
self.asset_type, self.diff_fields, self.push_fields, self.get_dependencies
class AssetCommand(click.Command):
""" Custom click command that will update the context with asset information
related to the command called.
asset_info = AssetInfo()
def invoke(self, ctx):
ctx.meta["asset_info"] = self.asset_info
return super().invoke(ctx)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment