carson 2.27.0 → 2.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b07e53b67d21543ee131ce2a8bbc906938fbd657f79973aaa59008911dd14df7
4
- data.tar.gz: 73d0811c01b3daa2f397dd545a266085950d93d4cda474ab3288b6b754cd5d20
3
+ metadata.gz: 7117079168b4f8472a4324f954bc087122e0ded0d253252b73702c41d3996283
4
+ data.tar.gz: 21484878bcafe5799dfd87a18c223b5982d6b2ff1ab988c78f929de9cd642bdd
5
5
  SHA512:
6
- metadata.gz: 9880a422abf831615af431cf9b32b6a28a0cd026f2154a46270664deb4d8d32dacf0dac4912a2e64984889372a43bd3cf36cd1cd87899c7b4e3c5cf7ae989fab
7
- data.tar.gz: 11e37eb20e6f62dd632493c134218a714dab0a565b533681b1f57b78f28f01dd799786d2d461285dd7623d2832b29f4d3e72f2d95a273f8c80e5869d49f72cd6
6
+ metadata.gz: bb4b347d7ace09997a93b40fc7ec179baf4eb8aee75a620e3511d4ac7b9c46545380f7157ac442807e09cc1a679e8709a62df1a237a41618501688162f99c511
7
+ data.tar.gz: 91aaf60433a82548170eb66eef14ce90c0eb730a3a56e06f7c154449d2355ca50f9a1e282d1b26e372c34b1df2946cb804587854875c14d1ffec3da5d6658bff
data/RELEASE.md CHANGED
@@ -5,6 +5,27 @@ Release-note scope rule:
5
5
  - `RELEASE.md` records only version deltas, breaking changes, and migration actions.
6
6
  - Operational usage guides live in `MANUAL.md` and `API.md`.
7
7
 
8
+ ## 2.28.0 — Non-Interactive CLI Flags for Setup
9
+
10
+ ### What changed
11
+
12
+ - **`carson setup` now accepts optional CLI flags** to configure settings without interactive prompts:
13
+ - `--remote NAME` sets `git.remote`
14
+ - `--main-branch NAME` sets `git.main_branch`
15
+ - `--workflow STYLE` sets `workflow.style` (branch or trunk)
16
+ - `--merge METHOD` sets `govern.merge.method` (squash, rebase, or merge)
17
+ - `--canonical PATH` sets `template.canonical`
18
+ - When any flag is present, interactive prompts are skipped and only the specified values are written.
19
+ - When no flags are present, existing behaviour is preserved (interactive in TTY, silent detection in non-TTY).
20
+
21
+ ### Why
22
+
23
+ Running `carson setup` in non-TTY environments (CI pipelines, agent scripts) previously required manually editing `config.json`. CLI flags allow fully automated configuration without file manipulation.
24
+
25
+ ### Migration
26
+
27
+ No action required. Existing behaviour is unchanged when no flags are provided.
28
+
8
29
  ## 2.27.0 — Absorbed Branch Pruning
9
30
 
10
31
  ### What changed
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.27.0
1
+ 2.28.0
data/lib/carson/cli.rb CHANGED
@@ -53,7 +53,7 @@ module Carson
53
53
 
54
54
  def self.build_parser
55
55
  OptionParser.new do |opts|
56
- opts.banner = "Usage: carson [setup|audit|sync|prune|onboard [repo_path]|refresh [--all|repo_path]|offboard [repo_path]|template check|template apply|review gate|review sweep|govern [--dry-run] [--json] [--loop SECONDS]|version]"
56
+ opts.banner = "Usage: carson [setup [--remote NAME] [--main-branch NAME] [--workflow STYLE] [--merge METHOD] [--canonical PATH]|audit|sync|prune|onboard [repo_path]|refresh [--all|repo_path]|offboard [repo_path]|template check|template apply|review gate|review sweep|govern [--dry-run] [--json] [--loop SECONDS]|version]"
57
57
  end
58
58
  end
59
59
 
@@ -74,6 +74,8 @@ module Carson
74
74
  when "version"
75
75
  parser.parse!( argv )
76
76
  { command: "version" }
77
+ when "setup"
78
+ parse_setup_command( argv: argv, parser: parser, err: err )
77
79
  when "onboard", "offboard"
78
80
  parse_repo_path_command( command: command, argv: argv, parser: parser, err: err )
79
81
  when "refresh"
@@ -90,6 +92,28 @@ module Carson
90
92
  end
91
93
  end
92
94
 
95
+ def self.parse_setup_command( argv:, parser:, err: )
96
+ options = {}
97
+ setup_parser = OptionParser.new do |opts|
98
+ opts.banner = "Usage: carson setup [--remote NAME] [--main-branch NAME] [--workflow STYLE] [--merge METHOD] [--canonical PATH]"
99
+ opts.on( "--remote NAME", "Git remote name" ) { |v| options[ "git.remote" ] = v }
100
+ opts.on( "--main-branch NAME", "Main branch name" ) { |v| options[ "git.main_branch" ] = v }
101
+ opts.on( "--workflow STYLE", "Workflow style (branch or trunk)" ) { |v| options[ "workflow.style" ] = v }
102
+ opts.on( "--merge METHOD", "Merge method (squash, rebase, or merge)" ) { |v| options[ "govern.merge.method" ] = v }
103
+ opts.on( "--canonical PATH", "Canonical template directory path" ) { |v| options[ "template.canonical" ] = v }
104
+ end
105
+ setup_parser.parse!( argv )
106
+ unless argv.empty?
107
+ err.puts "#{BADGE} Unexpected arguments for setup: #{argv.join( ' ' )}"
108
+ err.puts setup_parser
109
+ return { command: :invalid }
110
+ end
111
+ { command: "setup", cli_choices: options }
112
+ rescue OptionParser::ParseError => e
113
+ err.puts "#{BADGE} #{e.message}"
114
+ { command: :invalid }
115
+ end
116
+
93
117
  def self.parse_repo_path_command( command:, argv:, parser:, err: )
94
118
  parser.parse!( argv )
95
119
  if argv.length > 1
@@ -209,7 +233,7 @@ module Carson
209
233
 
210
234
  case command
211
235
  when "setup"
212
- runtime.setup!
236
+ runtime.setup!( cli_choices: parsed.fetch( :cli_choices, {} ) )
213
237
  when "audit"
214
238
  runtime.audit!
215
239
  when "sync"
@@ -6,13 +6,17 @@ module Carson
6
6
  module Setup
7
7
  WELL_KNOWN_REMOTES = %w[origin github upstream].freeze
8
8
 
9
- def setup!
9
+ def setup!( cli_choices: {} )
10
10
  puts_verbose ""
11
11
  puts_verbose "[Setup]"
12
12
 
13
13
  unless inside_git_work_tree?
14
14
  puts_line "WARN: not a git repository. Skipping remote and branch detection."
15
- return write_setup_config( choices: {} )
15
+ return write_setup_config( choices: cli_choices )
16
+ end
17
+
18
+ unless cli_choices.empty?
19
+ return write_setup_config( choices: cli_choices )
16
20
  end
17
21
 
18
22
  if self.in.respond_to?( :tty? ) && self.in.tty?
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: carson
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.27.0
4
+ version: 2.28.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hailei Wang