Commit 8418f52d authored by Matthieu Gonnet's avatar Matthieu Gonnet Committed by Sebastien Luttringer
Browse files

add --force option to clean command

execute clean command without asking confirmation
parent fba78c61
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -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
+1 −1
Original line number Diff line number Diff line
@@ -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)
+2 −2
Original line number Diff line number Diff line
@@ -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")