Sha256: 2cb86f7e3e43cfe0fd6f955f29d8c5461a56077eac9b198715e346970fb02d54

Contents?: true

Size: 1.15 KB

Versions: 7

Compression:

Stored size: 1.15 KB

Contents

require 'sct/command_interface'
require 'highline'

module Sct

  class InitCommand

    IS_PUBLIC_COMMAND = true
    SYNTAX = 'sct init'
    SUMMARY = 'Initialize a base configuration file for sct'
    EXAMPLE = 'sct init'
    EXAMPLE_DESCRIPTION = 'sct init will create a configuration file'
    DESCRIPTION = "sct init will create a configuration file"

    OPTIONS = []

    def initialize
    end

    def execute(args, options)

      Sct::Config.dir

      cli = HighLine.new

      email = cli.ask("What is your email address?") { |q|
          q.validate = URI::MailTo::EMAIL_REGEXP
      }

      cloud_proxy_path = cli.ask("What is the path of your cloud proxy json credentials?") { |q|
          q.default = "~/.config/gcloud/application_default_credentials.json"
      }

      contents = ""
      contents << "email=#{email}\n"
      contents << "cloud-proxy-path=#{File.expand_path(cloud_proxy_path)}\n"

      if !File.directory?(Sct::Config.dir)
          FileUtils.mkdir_p(Sct::Config.dir)
      end

      File.write(Sct::Config.path, contents)

      puts "Generated config file at #{Sct::Config.path}"
    end

    implements CommandInterface

  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
sct-0.1.18 lib/sct/commands/init.rb
sct-0.1.17 lib/sct/commands/init.rb
sct-0.1.16 lib/sct/commands/init.rb
sct-0.1.15 lib/sct/commands/init.rb
sct-0.1.14 lib/sct/commands/init.rb
sct-0.1.13 lib/sct/commands/init.rb
sct-0.1.12 lib/sct/commands/init.rb