Deployment and lifecycle management for Nix
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

cli: if debug is enabled, use simple output

+42 -15
+2 -1
apps/sower_cli/lib/sower_cli/build.ex
··· 85 85 defp run_steps([:eval | rest], %__MODULE__{} = state) do 86 86 Output.step("Evaluating #{state.flake}") 87 87 88 - Application.ensure_all_started([:erlexec, :owl]) 88 + Application.ensure_all_started([:erlexec]) 89 + Output.init(debug: state.flags.debug) 89 90 90 91 opts = [ 91 92 workers: state.options.eval_jobs,
+40 -14
apps/sower_cli/lib/sower_cli/output.ex
··· 4 4 """ 5 5 6 6 @doc """ 7 - Ensure Owl.LiveScreen is started. 7 + Initialize output mode. When debug is true, uses simple line-by-line output. 8 + When false, uses Owl.LiveScreen for in-place updates. 8 9 """ 9 - def ensure_live_screen do 10 - Application.ensure_all_started(:owl) 10 + def init(opts \\ []) do 11 + if opts[:debug] do 12 + Process.put(:output_mode, :simple) 13 + else 14 + Application.ensure_all_started(:owl) 15 + Process.put(:output_mode, :live) 16 + end 11 17 end 18 + 19 + defp live_mode?, do: Process.get(:output_mode, :live) == :live 12 20 13 21 @doc """ 14 22 Print a step header. ··· 40 48 41 49 @doc """ 42 50 Add a live-updating item block. Returns the block_id for later updates. 51 + In simple mode, prints start message immediately. 43 52 """ 44 53 def live_item_start(block_id, action, name) do 45 - Owl.LiveScreen.add_block(block_id, 46 - state: {action, name, :pending}, 47 - render: &render_item/1 48 - ) 54 + if live_mode?() do 55 + Owl.LiveScreen.add_block(block_id, 56 + state: {action, name, :pending}, 57 + render: &render_item/1 58 + ) 59 + Owl.LiveScreen.await_render() 60 + else 61 + IO.puts(" #{IO.ANSI.yellow()}⋯#{IO.ANSI.reset()} #{action} #{name}") 62 + end 49 63 50 - Owl.LiveScreen.await_render() 51 64 block_id 52 65 end 53 66 54 67 @doc """ 55 68 Update a live item to show completion. 69 + In simple mode, prints completion message. 56 70 """ 57 71 def live_item_done(block_id, action, name) do 58 - Owl.LiveScreen.update(block_id, {action, name, :ok}) 59 - Owl.LiveScreen.await_render() 72 + if live_mode?() do 73 + Owl.LiveScreen.update(block_id, {action, name, :ok}) 74 + Owl.LiveScreen.await_render() 75 + else 76 + IO.puts(" #{IO.ANSI.green()}✓#{IO.ANSI.reset()} #{action} #{name}") 77 + end 60 78 end 61 79 62 80 @doc """ 63 81 Update a live item to show error. 82 + In simple mode, prints error message. 64 83 """ 65 84 def live_item_error(block_id, action, name) do 66 - Owl.LiveScreen.update(block_id, {action, name, :error}) 67 - Owl.LiveScreen.await_render() 85 + if live_mode?() do 86 + Owl.LiveScreen.update(block_id, {action, name, :error}) 87 + Owl.LiveScreen.await_render() 88 + else 89 + IO.puts(" #{IO.ANSI.red()}✗#{IO.ANSI.reset()} #{action} #{name}") 90 + end 68 91 end 69 92 70 93 defp render_item({action, name, :pending}) do ··· 81 104 82 105 @doc """ 83 106 Flush all live blocks and render final state. 107 + No-op in simple mode. 84 108 """ 85 109 def live_flush do 86 - Owl.LiveScreen.await_render() 87 - Owl.LiveScreen.flush() 110 + if live_mode?() do 111 + Owl.LiveScreen.await_render() 112 + Owl.LiveScreen.flush() 113 + end 88 114 end 89 115 90 116 @doc """