bin/braid in braid-1.0.20 vs bin/braid in braid-1.0.21

- old
+ new

@@ -18,10 +18,23 @@ All operations will be executed in the braid/track branch. You can then merge back or cherry-pick changes. TXT + # Duplicated from Braid::Command.run. :( + def die(msg) + puts "Braid: Error: #{msg}" + exit(1) + end + + # The "main" library doesn't provide a way to do this?? + def check_no_extra_args! + if @argv.length > 0 + die 'Extra argument(s) passed to command.' + end + end + mode(:add) { description <<-TXT Add a new mirror to be tracked. * adds metadata about the mirror to .braids.json @@ -41,10 +54,11 @@ TXT mixin :argument_url, :optional_local_path, :option_branch, :option_tag, :option_revision, :option_verbose, :option_path run { + check_no_extra_args! Braid.verbose = verbose Braid::Command.run(:add, url, {'path' => local_path, 'branch' => branch, 'tag' => tag, 'revision' => revision, 'remote_path' => path}) } } @@ -66,10 +80,11 @@ TXT mixin :optional_local_path, :option_head, :option_revision, :option_tag, :option_branch, :option_verbose, :option_keep_remote run { + check_no_extra_args! options = { 'branch' => branch, 'tag' => tag, 'revision' => revision, 'head' => head, @@ -94,10 +109,11 @@ TXT mixin :argument_local_path, :option_verbose, :option_keep_remote run { + check_no_extra_args! options = { :keep => keep } Braid.verbose = verbose Braid::Command.run(:remove, local_path, options) @@ -105,17 +121,28 @@ } mode(:diff) { description <<-TXT Show diff of local changes to mirror. + + Additional arguments for "git diff" may be passed. "--" should be used to + ensure they are not parsed as Braid options. File paths to limit the diff are + relative to the downstream repository (for more convenient completion), even + though file paths in the diff are relative to the mirror. TXT mixin :optional_local_path, :option_verbose, :option_keep_remote + synopsis (Main::Usage.default_synopsis(self) + ' [-- git_diff_arg*]') + run { + if @argv.length > 0 && @argv[0] == '--' + @argv.shift + end options = { - 'keep' => keep + 'keep' => keep, + 'git_diff_args' => @argv } Braid.verbose = verbose Braid::Command.run(:diff, local_path, options) } } @@ -126,10 +153,11 @@ TXT mixin :argument_local_path, :option_branch, :option_verbose, :option_keep_remote run { + check_no_extra_args! options = { 'keep' => keep, 'branch' => branch } Braid.verbose = verbose @@ -143,29 +171,32 @@ TXT mixin :optional_local_path, :option_verbose, :option_force run { + check_no_extra_args! Braid.verbose = verbose Braid.force = force Braid::Command.run(:setup, local_path) } } mode(:version) { description 'Show braid version.' run { + check_no_extra_args! puts "braid #{Braid::VERSION}" } } mode(:status) { description 'Show the status of all tracked mirrors (and if updates are available).' mixin :optional_local_path, :option_verbose run { + check_no_extra_args! Braid.verbose = verbose Braid::Command.run(:status, local_path) } }