IF YOU WOULD LIKE TO GET AN ACCOUNT, please write an email to s dot adaszewski at gmail dot com. User accounts are meant only to report issues and/or generate pull requests. This is a purpose-specific Git hosting for ADARED projects. Thank you for your understanding!
Selaa lähdekoodia

Simplify syntax

tags/0.92
Stanislaw Adaszewski 4 vuotta sitten
vanhempi
commit
515985a797
1 muutettua tiedostoa jossa 22 lisäystä ja 43 poistoa
  1. +22
    -43
      focker.py

+ 22
- 43
focker.py Näytä tiedosto

@@ -37,7 +37,7 @@ class ListForwarderFunctor(object):
res = []
for elem in self.lst:
res.append(elem(*args, **kwargs))
return res
return ListForwarder(res)
class ListForwarder(object):
@@ -65,34 +65,28 @@ def create_parser():
subparsers = ListForwarder([ subparsers_top.add_parser(cmd).add_subparsers(dest='L2_command') \
for cmd in ['image', 'i'] ])
subparsers.required = True
parser = ListForwarder(reduce(lambda a, b: a + b,
[subparsers.add_parser(cmd) for cmd in ['build', 'b']]))
parser = ListForwarder([subparsers.add_parser(cmd) for cmd in ['build', 'b']])
parser.set_defaults(func=command_image_build)
parser.add_argument('focker_dir', type=str)
parser.add_argument('--tags', '-t', type=str, nargs='+', default=[])
parser = ListForwarder(reduce(lambda a, b: a + b,
[subparsers.add_parser(cmd) for cmd in ['tag', 't']]))
parser = ListForwarder([subparsers.add_parser(cmd) for cmd in ['tag', 't']])
parser.set_defaults(func=command_image_tag)
parser.add_argument('reference', type=str)
parser.add_argument('tags', type=str, nargs='+')
parser = ListForwarder(reduce(lambda a, b: a + b,
[subparsers.add_parser(cmd) for cmd in ['untag', 'u']]))
parser = ListForwarder([subparsers.add_parser(cmd) for cmd in ['untag', 'u']])
parser.set_defaults(func=command_image_untag)
parser.add_argument('tags', type=str, nargs='+', default=[])
parser = ListForwarder(reduce(lambda a, b: a + b,
[subparsers.add_parser(cmd) for cmd in ['list', 'ls', 'l']]))
parser = ListForwarder([subparsers.add_parser(cmd) for cmd in ['list', 'ls', 'l']])
parser.set_defaults(func=command_image_list)
parser.add_argument('--full-sha256', '-f', action='store_true')
parser = ListForwarder(reduce(lambda a, b: a + b,
[subparsers.add_parser(cmd) for cmd in ['prune', 'p']]))
parser = ListForwarder([subparsers.add_parser(cmd) for cmd in ['prune', 'p']])
parser.set_defaults(func=command_image_prune)
parser = ListForwarder(reduce(lambda a, b: a + b,
[subparsers.add_parser(cmd) for cmd in ['remove', 'r']]))
parser = ListForwarder([subparsers.add_parser(cmd) for cmd in ['remove', 'r']])
parser.set_defaults(func=command_image_remove)
parser.add_argument('reference', type=str)
# parser.add_argument('--remove-children', '-r', action='store_true')
@@ -102,8 +96,7 @@ def create_parser():
subparsers = ListForwarder([ subparsers_top.add_parser(cmd).add_subparsers(dest='L2_command') \
for cmd in ['jail', 'j'] ])
subparsers.required = True
parser = ListForwarder(reduce(lambda a, b: a + b,
[subparsers.add_parser(cmd) for cmd in ['create', 'c']]))
parser = ListForwarder([subparsers.add_parser(cmd) for cmd in ['create', 'c']])
parser.set_defaults(func=command_jail_create)
parser.add_argument('image', type=str)
parser.add_argument('--command', '-c', type=str, default='/bin/sh')
@@ -112,53 +105,44 @@ def create_parser():
parser.add_argument('--mounts', '-m', type=str, nargs='+', default=[])
parser.add_argument('--hostname', '-n', type=str)
parser = ListForwarder(reduce(lambda a, b: a + b,
[subparsers.add_parser(cmd) for cmd in ['start', 's']]))
parser = ListForwarder([subparsers.add_parser(cmd) for cmd in ['start', 's']])
parser.set_defaults(func=command_jail_start)
parser.add_argument('reference', type=str)
parser = ListForwarder(reduce(lambda a, b: a + b,
[subparsers.add_parser(cmd) for cmd in ['stop', 'S']]))
parser = ListForwarder([subparsers.add_parser(cmd) for cmd in ['stop', 'S']])
parser.set_defaults(func=command_jail_stop)
parser.add_argument('reference', type=str)
parser = ListForwarder(reduce(lambda a, b: a + b,
[subparsers.add_parser(cmd) for cmd in ['remove', 'r']]))
parser = ListForwarder([subparsers.add_parser(cmd) for cmd in ['remove', 'r']])
parser.set_defaults(func=command_jail_remove)
parser.add_argument('reference', type=str)
parser = ListForwarder(reduce(lambda a, b: a + b,
[subparsers.add_parser(cmd) for cmd in ['exec', 'e']]))
parser = ListForwarder([subparsers.add_parser(cmd) for cmd in ['exec', 'e']])
parser.set_defaults(func=command_jail_exec)
parser.add_argument('reference', type=str)
parser.add_argument('command', type=str, nargs=argparse.REMAINDER, default=['/bin/sh'])
parser = ListForwarder(reduce(lambda a, b: a + b,
[subparsers.add_parser(cmd) for cmd in ['oneshot', 'o']]))
parser = ListForwarder([subparsers.add_parser(cmd) for cmd in ['oneshot', 'o']])
parser.set_defaults(func=command_jail_oneshot)
parser.add_argument('image', type=str)
parser.add_argument('--env', '-e', type=str, nargs='+', default=[])
parser.add_argument('--mounts', '-m', type=str, nargs='+', default=[])
parser.add_argument('command', type=str, nargs=argparse.REMAINDER, default=['/bin/sh'])
parser = ListForwarder(reduce(lambda a, b: a + b,
[subparsers.add_parser(cmd) for cmd in ['list', 'ls', 'l']]))
parser = ListForwarder([subparsers.add_parser(cmd) for cmd in ['list', 'ls', 'l']])
parser.set_defaults(func=command_jail_list)
parser.add_argument('--full-sha256', '-f', action='store_true')
parser = ListForwarder(reduce(lambda a, b: a + b,
[subparsers.add_parser(cmd) for cmd in ['tag', 't']]))
parser = ListForwarder([subparsers.add_parser(cmd) for cmd in ['tag', 't']])
parser.set_defaults(func=command_jail_tag)
parser.add_argument('reference', type=str)
parser.add_argument('tags', type=str, nargs='+')
parser = ListForwarder(reduce(lambda a, b: a + b,
[subparsers.add_parser(cmd) for cmd in ['untag', 'u']]))
parser = ListForwarder([subparsers.add_parser(cmd) for cmd in ['untag', 'u']])
parser.set_defaults(func=command_jail_untag)
parser.add_argument('tags', type=str, nargs='+')
parser = ListForwarder(reduce(lambda a, b: a + b,
[subparsers.add_parser(cmd) for cmd in ['prune', 'p']]))
parser = ListForwarder([subparsers.add_parser(cmd) for cmd in ['prune', 'p']])
parser.set_defaults(func=command_jail_prune)
parser.add_argument('--force', '-f', action='store_true')
@@ -166,28 +150,23 @@ def create_parser():
subparsers = ListForwarder([ subparsers_top.add_parser(cmd).add_subparsers(dest='L2_command') \
for cmd in ['volume', 'v'] ])
subparsers.required = True
parser = ListForwarder(reduce(lambda a, b: a + b,
[subparsers.add_parser(cmd) for cmd in ['create', 'c']]))
parser = ListForwarder([subparsers.add_parser(cmd) for cmd in ['create', 'c']])
parser.set_defaults(func=command_volume_create)
parser.add_argument('--tags', '-t', type=str, nargs='+', default=[])
parser = ListForwarder(reduce(lambda a, b: a + b,
[subparsers.add_parser(cmd) for cmd in ['prune', 'p']]))
parser = ListForwarder([subparsers.add_parser(cmd) for cmd in ['prune', 'p']])
parser.set_defaults(func=command_volume_prune)
parser = ListForwarder(reduce(lambda a, b: a + b,
[subparsers.add_parser(cmd) for cmd in ['list', 'ls', 'l']]))
parser = ListForwarder([subparsers.add_parser(cmd) for cmd in ['list', 'ls', 'l']])
parser.set_defaults(func=command_volume_list)
parser.add_argument('--full-sha256', '-f', action='store_true')
parser = ListForwarder(reduce(lambda a, b: a + b,
[subparsers.add_parser(cmd) for cmd in ['tag', 't']]))
parser = ListForwarder([subparsers.add_parser(cmd) for cmd in ['tag', 't']])
parser.set_defaults(func=command_volume_tag)
parser.add_argument('reference', type=str)
parser.add_argument('tags', type=str, nargs='+')
parser = ListForwarder(reduce(lambda a, b: a + b,
[subparsers.add_parser(cmd) for cmd in ['untag', 'u']]))
parser = ListForwarder([subparsers.add_parser(cmd) for cmd in ['untag', 'u']])
parser.set_defaults(func=command_volume_untag)
parser.add_argument('tags', type=str, nargs='+')


Loading…
Peruuta
Tallenna