Module: Carson::Runtime::Status
- Included in:
- Carson::Runtime
- Defined in:
- lib/carson/runtime/status.rb
Instance Method Summary collapse
-
#status!(json_output: false) ⇒ Object
Entry point for ‘carson status`.
-
#status_all!(json_output: false) ⇒ Object
Portfolio-wide status overview across all governed repositories.
Instance Method Details
#status!(json_output: false) ⇒ Object
Entry point for ‘carson status`. Collects estate state and reports.
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/carson/runtime/status.rb', line 8 def status!( json_output: false ) data = gather_status if json_output out.puts JSON.pretty_generate( data ) else print_status( data: data ) end EXIT_OK end |
#status_all!(json_output: false) ⇒ Object
Portfolio-wide status overview across all governed repositories.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 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 |
# File 'lib/carson/runtime/status.rb', line 21 def status_all!( json_output: false ) repos = config.govern_repos if repos.empty? puts_line "No governed repositories configured." puts_line " Run carson onboard in each repo to register." return EXIT_ERROR end if json_output results = [] repos.each do |repo_path| repo_name = File.basename( repo_path ) unless Dir.exist?( repo_path ) results << { name: repo_name, status: "error", error: "path not found" } next end begin rt = build_scoped_runtime( repo_path: repo_path ) data = rt.send( :gather_status ) results << { name: repo_name, status: "ok" }.merge( data ) rescue StandardError => e results << { name: repo_name, status: "error", error: e. } end end out.puts JSON.pretty_generate( { command: "status", repos: results } ) return EXIT_OK end puts_line "Carson #{Carson::VERSION} — Portfolio (#{repos.length} repo#{plural_suffix( count: repos.length )})" puts_line "" all_pending = load_batch_pending repos.each do |repo_path| repo_name = File.basename( repo_path ) unless Dir.exist?( repo_path ) puts_line "#{repo_name}: MISSING" next end begin rt = build_scoped_runtime( repo_path: repo_path ) data = rt.send( :gather_status ) branch = data.fetch( :branch ) dirty = branch.fetch( :dirty ) ? " (dirty)" : "" worktrees = data.fetch( :worktrees ) gov = data.fetch( :governance ) parts = [] parts << branch.fetch( :name ) + dirty parts << "#{worktrees.count} worktree#{plural_suffix( count: worktrees.count )}" if worktrees.any? parts << "templates #{gov.fetch( :templates )}" unless gov.fetch( :templates ) == :in_sync puts_line "#{repo_name}: #{parts.join( ' ' )}" # Show pending operations for this repo. repo_pending = status_pending_for_repo( all_pending: all_pending, repo_path: repo_path ) repo_pending.each { |desc| puts_line " pending: #{desc}" } rescue StandardError => e puts_line "#{repo_name}: FAIL (#{e.})" end end EXIT_OK end |