diff --git a/bin/is b/bin/is index f1b379e5189c9b88e78617b4f5c53e6fc4203c76..325d8b680a0312d7d3358b5895aa184357d234dd 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 ac8fe27a014455c9eb312b8043557a351a1e1c39..f981c915cc27bf4263a3bbf30d53be8dab698aa8 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 84ef4f2eba860aac29bece6a0fc971c510650e5c..d676a6c0ee7b9acebb790bdb190a770c23c80409 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")