#!/usr/bin/env ruby # $LOAD_PATH << 'lib' require 'rubygems' require 'commander/import' require 'secrets_cli' program :version, SecretsCli::VERSION program :description, 'CLI for vault' global_option '-V', '--verbose', 'Verbose' command :init do |c| c.syntax = 'secrets init [options]' c.summary = 'Use to initialize project, create .secrets file' c.option '-f', '--secrets_file STRING', String, 'Define secrets file' c.option '-r', '--secrets_repo STRING', String, 'Define secrets repo' c.option '-F', '--secrets_field STRING', String, 'Define secrets field' c.action do |_args, options| SecretsCli::Init.new(options).call end end command :auth do |c| c.syntax = 'secrets auth [options]' c.summary = 'Use to authenticate with vault server' c.option '-T', '--auth_token STRING', String, 'Auth token or $SECRETS_VAULT_AUTH_TOKEN' c.option '-m', '--auth_method STRING', String, 'github or token' c.action do |_args, options| SecretsCli::Check::Vault.new(options).call SecretsCli::Vault::Auth.new(options).call end end command :pull do |c| c.syntax = 'secrets pull [options]' c.summary = 'Use to read from vault server to secrets file' c.option '-e', '--environment STRING', String, 'Set environment, default: development' c.option '-f', '--secrets_file STRING', String, 'Override secrets_file' c.option '-r', '--secrets_repo STRING', String, 'Override secrets_repo' c.option '-F', '--secrets_field STRING', String, 'Override secrets_field' c.option '-d', '--secrets_dir STRING', String, 'Override secrets_dir, default: "."' c.action do |_args, options| SecretsCli::Check::Secrets.new(options).call SecretsCli::Vault::Pull.new(options).call end end command :push do |c| c.syntax = 'secrets push [options]' c.summary = 'Use to write to vault server from secrets file' c.option '-y', '--without_prompt', 'Push without prompt' c.option '-e', '--environment STRING', String, 'Set environment, default: development' c.option '-f', '--secrets_file STRING', String, 'Override secrets_file' c.option '-r', '--secrets_repo STRING', String, 'Override secrets_repo' c.option '-F', '--secrets_field STRING', String, 'Override secrets_field' c.action do |_args, options| SecretsCli::Check::Secrets.new(options).call SecretsCli::Vault::Push.new(options).call end end command :read do |c| c.syntax = 'secrets read [options]' c.summary = 'Use to only read from vault server without writing to secrets file' c.option '-e', '--environment STRING', String, 'Set environment, default: development' c.option '-r', '--secrets_repo STRING', String, 'Override secrets_repo' c.option '-F', '--secrets_field STRING', String, 'Override secrets_field' c.action do |_args, options| SecretsCli::Check::Secrets.new(options).call SecretsCli::Vault::Read.new(options).call end end