Beispiel #1
0
def cli_rename(api: GbdApi, args):
    if not api.feature_exists(args.old_name):
        eprint("Feature '{}' does not exist or is virtual".format(
            args.old_name))
    elif api.feature_exists(args.new_name):
        eprint("Feature '{}' does already exist".format(args.new_name))
    else:
        api.rename_feature(args.old_name, args.new_name)
Beispiel #2
0
def cli_delete(api: GbdApi, args):
    if api.feature_exists(args.name):
        if (not args.hashes
                or len(args.hashes) == 0) and not sys.stdin.isatty():
            args.hashes = read_hashes()
        if args.hashes and len(args.hashes) > 0:
            if args.force or confirm(
                    "Delete attributes of given hashes from '{}'?".format(
                        args.name)):
                api.remove_attributes(args.name, args.hashes)
        elif args.force or confirm(
                "Delete feature '{}' and all associated attributes?".format(
                    args.name)):
            api.remove_feature(args.name)
    else:
        eprint("Feature '{}' does not exist or is virtual".format(args.name))
Beispiel #3
0
def cli_create(api: GbdApi, args):
    if not api.feature_exists(args.name):
        api.create_feature(args.name, args.unique)
    else:
        eprint("Feature '{}' does already exist".format(args.name))