lib/modulesync/cli.rb in modulesync-0.5.0 vs lib/modulesync/cli.rb in modulesync-0.6.0

- old
+ new

@@ -12,10 +12,11 @@ :branch => 'master', :git_base => 'git@github.com:', :managed_modules_conf => 'managed_modules.yml', :configs => '.', :tag_pattern => '%s', + :project_root => './modules', } end def commands_available [ @@ -33,11 +34,11 @@ def parse_opts(args) @options = defaults @options.merge!(Hash.transform_keys_to_symbols(Util.parse_config(MODULESYNC_CONF_FILE))) @options[:command] = args[0] if commands_available.include?(args[0]) opt_parser = OptionParser.new do |opts| - opts.banner = "Usage: msync update [-m <commit message>] [-c <directory> ] [--noop] [--bump] [--changelog] [--tag] [--tag-pattern <tag_pattern>] [-n <namespace>] [-b <branch>] [-r <branch>] [-f <filter>] | hook activate|deactivate [-c <directory> ] [-n <namespace>] [-b <branch>]" + opts.banner = "Usage: msync update [-m <commit message>] [-c <directory> ] [--offline] [--noop] [--bump] [--changelog] [--tag] [--tag-pattern <tag_pattern>] [-p <project_root> [-n <namespace>] [-b <branch>] [-r <branch>] [-f <filter>] | hook activate|deactivate [-c <directory> ] [-n <namespace>] [-b <branch>]" opts.on('-m', '--message <msg>', 'Commit message to apply to updated modules') do |msg| @options[:message] = msg end opts.on('-n', '--namespace <url>', @@ -50,10 +51,14 @@ end opts.on('-b', '--branch <branch>', 'Branch name to make the changes in. Defaults to "master"') do |branch| @options[:branch] = branch end + opts.on('-p', '--project-root <path>', + 'Path used by git to clone modules into. Defaults to "modules"') do |project_root| + @options[:project_root] = project_root + end opts.on('-r', '--remote-branch <branch>', 'Remote branch name to push the changes to. Defaults to the branch name') do |branch| @options[:remote_branch] = branch end opts.on('-f', '--filter <filter>', @@ -70,10 +75,14 @@ end opts.on('--noop', 'No-op mode') do |msg| @options[:noop] = true end + opts.on('--offline', + 'Do not run git command. Helpful if you have existing repositories locally.') do |msg| + @options[:offline] = true + end opts.on('--bump', 'Bump module version to the next minor') do |msg| @options[:bump] = true end opts.on('--changelog', @@ -90,11 +99,11 @@ end @options[:help] = opts.help end.parse! @options.fetch(:message) do - if @options[:command] == 'update' && ! @options[:noop] && ! @options[:amend] - fail("A commit message is required unless using noop.") + if @options[:command] == 'update' && ! @options[:noop] && ! @options[:amend] && ! @options[:offline] + fail("A commit message is required unless using noop or offline.") end end @options.fetch(:command) do fail("A command is required.")