Class: SashimiTanpopo::CLI
- Inherits:
-
Thor
- Object
- Thor
- SashimiTanpopo::CLI
- Defined in:
- lib/sashimi_tanpopo/cli.rb
Class Method Summary collapse
- .define_exec_common_options ⇒ Object
- .exit_on_failure? ⇒ Boolean
- .normalize_params(params) ⇒ Hash<Symbol,String>
Instance Method Summary collapse
- #github(*recipe_files) ⇒ Object
- #gitlab(*recipe_files) ⇒ Object
- #local(*recipe_files) ⇒ Object
- #version ⇒ Object
Class Method Details
.define_exec_common_options ⇒ Object
17 18 19 20 21 22 |
# File 'lib/sashimi_tanpopo/cli.rb', line 17 def self. option :target_dir, type: :string, aliases: "-d", desc: "Target directory. Default: current directory" option :params, type: :hash, aliases: "-p", default: {}, desc: "Params passed to recipe file", repeatable: true option :dry_run, type: :boolean, default: false, desc: "Whether to run dry run" option :color, type: :boolean, default: true, desc: "Whether to colorize output" end |
.exit_on_failure? ⇒ Boolean
13 14 15 |
# File 'lib/sashimi_tanpopo/cli.rb', line 13 def self.exit_on_failure? true end |
.normalize_params(params) ⇒ Hash<Symbol,String>
142 143 144 |
# File 'lib/sashimi_tanpopo/cli.rb', line 142 def self.normalize_params(params) params.transform_keys(&:to_sym) end |
Instance Method Details
#github(*recipe_files) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/sashimi_tanpopo/cli.rb', line 55 def github(*recipe_files) repository = option_or_env!(option_name: :github_repository, env_name: "GITHUB_REPOSITORY") api_endpoint = option_or_env!(option_name: :github_api_url, env_name: "GITHUB_API_URL") access_token = option_or_env!(option_name: :github_token, env_name: "GITHUB_TOKEN") summary_path = option_or_env(option_name: :github_step_summary, env_name: "GITHUB_STEP_SUMMARY") raise ArgumentError, "`--pr-auto-merge` and `--pr-draft` cannot be used together." if [:pr_auto_merge] && [:pr_draft] Provider::GitHub.new( recipe_paths: recipe_files, target_dir: [:target_dir], params: self.class.normalize_params([:params]), dry_run: [:dry_run], is_colored: [:color], git_username: [:git_user_name], git_email: [:git_email], commit_message: [:message], repository: repository, api_endpoint: api_endpoint, access_token: access_token, pr_title: [:pr_title], pr_body: [:pr_body], pr_source_branch: [:pr_source_branch], pr_target_branch: [:pr_target_branch], pr_assignees: [:pr_assignees], pr_reviewers: [:pr_reviewers], pr_labels: [:pr_labels], pr_auto_merge: [:pr_auto_merge], is_draft_pr: [:pr_draft], summary_path: summary_path, only_changes_summary: [:only_changes_summary], ).perform end |
#gitlab(*recipe_files) ⇒ Object
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/sashimi_tanpopo/cli.rb', line 107 def gitlab(*recipe_files) repository = option_or_env!(option_name: :gitlab_project, env_name: %w[GITLAB_PROJECT CI_PROJECT_PATH]) api_endpoint = option_or_env!(option_name: :gitlab_api_url, env_name: %w[GITLAB_API_URL CI_API_V4_URL]) access_token = option_or_env!(option_name: :gitlab_token, env_name: "GITLAB_TOKEN") Provider::GitLab.new( recipe_paths: recipe_files, target_dir: [:target_dir], params: self.class.normalize_params([:params]), dry_run: [:dry_run], is_colored: [:color], git_username: [:git_user_name], git_email: [:git_email], commit_message: [:message], repository: repository, api_endpoint: api_endpoint, access_token: access_token, mr_title: [:mr_title], mr_body: [:mr_body], mr_source_branch: [:mr_source_branch], mr_target_branch: [:mr_target_branch], mr_assignees: [:mr_assignees], mr_reviewers: [:mr_reviewers], mr_labels: [:mr_labels], is_draft_mr: [:mr_draft], is_auto_merge: [:mr_auto_merge], ).perform end |
#local(*recipe_files) ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'lib/sashimi_tanpopo/cli.rb', line 26 def local(*recipe_files) Provider::Local.new( recipe_paths: recipe_files, target_dir: [:target_dir], params: self.class.normalize_params([:params]), dry_run: [:dry_run], is_colored: [:color], ).perform end |
#version ⇒ Object
9 10 11 |
# File 'lib/sashimi_tanpopo/cli.rb', line 9 def version puts "sashimi_tanpopo v#{SashimiTanpopo::VERSION}" end |