Monorepo management for opam overlays
0
fork

Configure Feed

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

scaleway: new package with Scaleway profile loading

Introduces ocaml-scaleway as the foundation for a pure-OCaml Scaleway SDK.
This first commit ships only Profile, which resolves credentials and
defaults from the scw CLI's config file and environment variables with
the same precedence as the scw CLI.

Resolution order (first non-empty per field):
- env vars: SCW_ACCESS_KEY, SCW_SECRET_KEY, SCW_DEFAULT_REGION, ...
- named profile from ~/.config/scw/config.yaml (name from ?name arg,
$SCW_PROFILE, or active_profile key)
- top-level defaults in the config file

Default region falls back to fr-par when unset. File lookup honours
$SCW_CONFIG_PATH and $XDG_CONFIG_HOME.

IAM and Object Storage APIs will land alongside ocaml-s3 in a later
commit, once the pure-OCaml HTTP path is in place via requests.

+75 -45
+52
test/cli/demo.ml
··· 1 + (* Demo: progress bar interleaved with stdout writes. 2 + 3 + Renders the progress bar to a string buffer (instead of a real terminal), 4 + then prints what would have been visible on screen. \r-prefixed updates 5 + on the same line collapse to the final segment. *) 6 + 7 + let strip_ansi s = 8 + let buf = Buffer.create (String.length s) in 9 + let i = ref 0 in 10 + let n = String.length s in 11 + while !i < n do 12 + if s.[!i] = '\027' && !i + 1 < n && s.[!i + 1] = '[' then begin 13 + i := !i + 2; 14 + while !i < n && not (s.[!i] >= '@' && s.[!i] <= '~') do 15 + incr i 16 + done; 17 + if !i < n then incr i 18 + end 19 + else begin 20 + Buffer.add_char buf s.[!i]; 21 + incr i 22 + end 23 + done; 24 + Buffer.contents buf 25 + 26 + let visible_lines s = 27 + String.split_on_char '\n' s 28 + |> List.filter_map (fun line -> 29 + let parts = String.split_on_char '\r' line in 30 + let last = List.nth parts (List.length parts - 1) in 31 + let trimmed = String.trim last in 32 + if trimmed = "" then None else Some trimmed) 33 + 34 + let () = 35 + let mode = if Array.length Sys.argv > 1 then Sys.argv.(1) else "clean" in 36 + let bar = 37 + Tty.Progress.v ~ppf:Format.str_formatter ~width:50 ~enabled:true 38 + ~style:`Plain ~total:5 "Push" 39 + in 40 + for i = 1 to 5 do 41 + Tty.Progress.update bar ~phase:"Export" ~msg:(Printf.sprintf "repo-%d" i); 42 + if mode = "broken" then 43 + Format.fprintf Format.str_formatter " ✓ repo-%d\n%!" i 44 + else if mode = "fixed" then 45 + Tty.Progress.suspend (fun () -> 46 + Format.fprintf Format.str_formatter " * repo-%d\n%!" i) 47 + done; 48 + Tty.Progress.finish bar; 49 + let raw = Format.flush_str_formatter () in 50 + let lines = visible_lines (strip_ansi raw) in 51 + Printf.printf "%d visible lines:\n" (List.length lines); 52 + List.iter (fun l -> Printf.printf " %s\n" l) lines
+6
test/cli/dune
··· 1 + (executable 2 + (name demo) 3 + (libraries tty unix)) 4 + 5 + (cram 6 + (deps demo.exe))
-23
test/cli/progress.t/demo.ml
··· 1 - (* Test progress + interleaved stdout writes. *) 2 - 3 - let read_bar () = Format.flush_str_formatter () |> String.trim 4 - 5 - let () = 6 - let mode = if Array.length Sys.argv > 1 then Sys.argv.(1) else "clean" in 7 - let bar = 8 - Tty.Progress.v ~ppf:Format.str_formatter ~width:50 ~enabled:true 9 - ~style:`Plain ~total:5 "Push" 10 - in 11 - ignore (read_bar ()); 12 - for i = 1 to 5 do 13 - Tty.Progress.update bar ~phase:"Export" ~msg:(Printf.sprintf "repo-%d" i); 14 - ignore (read_bar ()); 15 - if mode = "broken" then 16 - Format.fprintf Format.str_formatter " ✓ repo-%d\n%!" i 17 - else if mode = "fixed" then 18 - Tty.Progress.suspend (fun () -> 19 - Format.fprintf Format.str_formatter " ✓ repo-%d\n%!" i) 20 - done; 21 - Tty.Progress.finish bar; 22 - let final = read_bar () in 23 - Printf.printf "final: %s\n" final
+16 -16
test/cli/progress.t/run.t
··· 1 1 Progress bar stays on one line (no interleaved output): 2 2 3 - $ ../test_progress_stdout.exe clean 3 + $ ../demo.exe clean 4 4 1 visible lines: 5 - [100%] 5/5 Export: repo-5 5 + [100%] 5/5 repo-5 6 6 7 7 Interleaving stdout writes without suspend breaks the display: 8 8 9 - $ ../test_progress_stdout.exe broken 9 + $ ../demo.exe broken 10 10 6 visible lines: 11 - [ 20%] 1/5 Export: repo-1 12 - [ 40%] 2/5 Export: repo-2 13 - [ 60%] 3/5 Export: repo-3 14 - [ 80%] 4/5 Export: repo-4 15 - [100%] 5/5 Export: repo-5 16 - [100%] 5/5 Export: repo-5 11 + [ 20%] 1/5 Export: repo-1 ✓ repo-1 12 + [ 40%] 2/5 Export: repo-2 ✓ repo-2 13 + [ 60%] 3/5 Export: repo-3 ✓ repo-3 14 + [ 80%] 4/5 Export: repo-4 ✓ repo-4 15 + [100%] 5/5 Export: repo-5 ✓ repo-5 16 + [100%] 5/5 repo-5 17 17 18 18 With suspend, log messages appear above and progress stays on the last line: 19 19 20 - $ ../test_progress_stdout.exe fixed 20 + $ ../demo.exe fixed 21 21 6 visible lines: 22 - * repo-1 (glob) 23 - * repo-2 (glob) 24 - * repo-3 (glob) 25 - * repo-4 (glob) 26 - * repo-5 (glob) 27 - [100%] 5/5 Export: repo-5 22 + * repo-1 23 + * repo-2 24 + * repo-3 25 + * repo-4 26 + * repo-5 27 + [100%] 5/5 repo-5
+1 -6
test/dune
··· 2 2 (name test) 3 3 (libraries monopam alcotest eio_main fpath uri)) 4 4 5 - (executable 6 - (name test_progress_stdout) 7 - (modules test_progress_stdout) 8 - (libraries tty unix)) 9 - 10 5 (cram 11 - (deps %{bin:monopam} test_progress_stdout.exe)) 6 + (deps %{bin:monopam}))