Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions lib/shell/shell.ml
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
let proc cmd =
Printf.eprintf "🐚 %s\n%!" cmd;
let _exit_code = Unix.system cmd in
()
match Unix.system cmd with
| Unix.WEXITED 0 -> Ok ()
| Unix.WEXITED return_code ->
Error
(Printf.sprintf "command '%s' failed with code %d" (String.escaped cmd)
return_code)
| Unix.WSIGNALED number | Unix.WSTOPPED number ->
Error
(Printf.sprintf "command '%s' was stopped by signal (%d)"
(String.escaped cmd) number)

let collect_chan (channel : in_channel) : string =
let rec loop acc =
Expand Down
2 changes: 1 addition & 1 deletion lib/shell/shell.mli
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Redirect the called process stdout and stderr to the current process stdout.

Also print the command with a pretty prompt. *)
val proc : string -> unit
val proc : string -> (unit, string) result

(** Run the given CLI command as external process and collect its stdout to the
resulting string. *)
Expand Down
6 changes: 5 additions & 1 deletion lib/tui/init/init.ml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ let clone_repo ~owner_repo ~local_path =
Printf.sprintf "git clone git@github.com:%s/%s.git %s" owner repo
temp_dir
in
Shell.proc cmd;
Shell.proc cmd
|> Result.iter_error (fun message ->
Printf.eprintf "❌ %s\n" message;
exit 1);

temp_dir

let read_root_tree ~root_dir_path =
Expand Down