From 8418f52dc4f5b0240d82e94f95225d7371e5665f Mon Sep 17 00:00:00 2001 From: Matthieu Gonnet Date: Mon, 30 Jan 2012 17:37:28 -0600 Subject: [PATCH] add --force option to clean command execute clean command without asking confirmation --- bin/is | 4 +++- completion/bash/is | 2 +- installsystems/repository.py | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/bin/is b/bin/is index f1b379e..325d8b6 100755 --- a/bin/is +++ b/bin/is @@ -235,7 +235,7 @@ def c_clean(args): ''' repoman = load_repositories(args) for reponame in args.repository: - repoman[reponame].clean() + repoman[reponame].clean(args.force) def c_copy(args): ''' @@ -542,6 +542,8 @@ def arg_parser_init(): p.set_defaults(func=c_chroot) # clean command parser p = subparser.add_parser("clean", help=c_clean.__doc__.lower()) + p.add_argument("-f", "--force", action="store_true", + help="clean repository without confirmation") p.add_argument("repository", nargs="+", help="repositories to clean") p.set_defaults(func=c_clean) # copy command parser diff --git a/completion/bash/is b/completion/bash/is index ac8fe27..f981c91 100644 --- a/completion/bash/is +++ b/completion/bash/is @@ -91,7 +91,7 @@ _is() { _filedir -d ;; clean) - [[ "$cur" == -* ]] && _opt '-h --help' && return 0 + [[ "$cur" == -* ]] && _opt '-h --help -f --force' && return 0 _local_repo ;; copy) diff --git a/installsystems/repository.py b/installsystems/repository.py index 84ef4f2..d676a6c 100644 --- a/installsystems/repository.py +++ b/installsystems/repository.py @@ -275,7 +275,7 @@ class Repository(object): if fo.md5 != f: out(f) - def clean(self): + def clean(self, force=False): ''' Clean the repository's content ''' @@ -291,7 +291,7 @@ class Repository(object): for f in dirtyfiles: arrow(f, 1) # ask confirmation - if not confirm("Remove dirty files? (yes) "): + if not force and not confirm("Remove dirty files? (yes) "): raise Exception("Aborted!") # start cleaning arrow("Cleaning") -- GitLab