diff options
Diffstat (limited to 'lib/leap_cli/commands')
| -rw-r--r-- | lib/leap_cli/commands/deploy.rb | 4 | ||||
| -rw-r--r-- | lib/leap_cli/commands/node.rb | 8 | ||||
| -rw-r--r-- | lib/leap_cli/commands/pre.rb | 3 | ||||
| -rw-r--r-- | lib/leap_cli/commands/project.rb | 8 | 
4 files changed, 13 insertions, 10 deletions
| diff --git a/lib/leap_cli/commands/deploy.rb b/lib/leap_cli/commands/deploy.rb index c2f98b8..337ef4d 100644 --- a/lib/leap_cli/commands/deploy.rb +++ b/lib/leap_cli/commands/deploy.rb @@ -15,13 +15,13 @@ module LeapCli        c.arg_name 'TAG[,TAG]'        c.flag :tags -      c.action do |global_options,options,args| +      c.action do |global,options,args|          init_submodules          nodes = manager.filter!(args)          if nodes.size > 1            say "Deploying to these nodes: #{nodes.keys.join(', ')}" -          unless agree "Continue? " +          if !global[:yes] && !agree("Continue? ")              quit! "OK. Bye."            end          end diff --git a/lib/leap_cli/commands/node.rb b/lib/leap_cli/commands/node.rb index 6a60c45..da29a02 100644 --- a/lib/leap_cli/commands/node.rb +++ b/lib/leap_cli/commands/node.rb @@ -45,12 +45,12 @@ module LeapCli; module Commands      node.arg_name '<node-filter>' #, :optional => false, :multiple => false      node.command :init do |init|        init.switch 'echo', :desc => 'If set, passwords are visible as you type them (default is hidden)', :negatable => false -      init.action do |global_options,options,args| +      init.action do |global,options,args|          assert! args.any?, 'You must specify a node-filter'          finished = []          manager.filter(args).each_node do |node|            ping_node(node) -          save_public_host_key(node) +          save_public_host_key(node, global)            update_compiled_ssh_configs            ssh_connect(node, :bootstrap => true, :echo => options[:echo]) do |ssh|              ssh.install_authorized_keys @@ -133,7 +133,7 @@ module LeapCli; module Commands    #    # see `man sshd` for the format of known_hosts    # -  def save_public_host_key(node) +  def save_public_host_key(node, global)      log :fetching, "public SSH host key for #{node.name}"      public_key = get_public_key_for_ip(node.ip_address, node.ssh.port)      pub_key_path = Path.named_path([:node_ssh_pub_key, node.name]) @@ -154,7 +154,7 @@ module LeapCli; module Commands        say("Type        -- #{public_key.bits} bit #{public_key.type.upcase}")        say("Fingerprint -- " + public_key.fingerprint)        say("Public Key  -- " + public_key.key) -      if !agree("Is this correct? ") +      if !global[:yes] && !agree("Is this correct? ")          bail!        else          puts diff --git a/lib/leap_cli/commands/pre.rb b/lib/leap_cli/commands/pre.rb index 26dce40..f10eb68 100644 --- a/lib/leap_cli/commands/pre.rb +++ b/lib/leap_cli/commands/pre.rb @@ -18,6 +18,9 @@ module LeapCli      desc 'Display version number and exit'      switch :version, :negatable => false +    desc 'Skip prompts and assume "yes"' +    switch :yes, :negatable => false +      pre do |global,command,options,args|        #        # set verbosity diff --git a/lib/leap_cli/commands/project.rb b/lib/leap_cli/commands/project.rb index 12d159b..fc3972f 100644 --- a/lib/leap_cli/commands/project.rb +++ b/lib/leap_cli/commands/project.rb @@ -9,7 +9,7 @@ module LeapCli; module Commands      c.flag 'name', :desc => "The name of the provider", :default_value => 'Example'      c.flag 'domain', :desc => "The primary domain of the provider", :default_value => 'example.org'      c.flag 'platform', :desc => "File path of the leap_platform directory", :default_value => '../leap_platform' -    c.action do |global_options, options, args| +    c.action do |global, options, args|        directory = args.first        unless directory && directory.any?          help! "Directory name is required." @@ -18,7 +18,7 @@ module LeapCli; module Commands        unless File.exists?(directory)          bail! { log :missing, "directory #{directory}" }        end -      create_initial_provider_files(directory, options) +      create_initial_provider_files(directory, global, options)      end    end @@ -29,7 +29,7 @@ module LeapCli; module Commands    #    # creates new provider directory    # -  def create_initial_provider_files(directory, options) +  def create_initial_provider_files(directory, global, options)      Path.set_provider_path(directory)      Dir.chdir(directory) do        assert_files_missing! 'provider.json', 'common.json', 'Leapfile', :base => directory @@ -37,7 +37,7 @@ module LeapCli; module Commands        platform_dir = File.expand_path(options[:platform])        unless File.symlink?(platform_dir) || File.directory?(platform_dir) -        if agree("The platform directory \"#{options[:platform]}\" does not exist.\nDo you want me to create it by cloning from the\ngit repository #{DEFAULT_REPO}? ") +        if global[:yes] || agree("The platform directory \"#{options[:platform]}\" does not exist.\nDo you want me to create it by cloning from the\ngit repository #{DEFAULT_REPO}? ")            assert_bin! 'git'            ensure_dir platform_dir            Dir.chdir(platform_dir) do | 
