Skip to content
Browse files

make opam remote works more like git remote

  • Loading branch information...
1 parent 64cc4d0 commit 05001d9fbb0e20451b10de318fc1d0c6e0910278 Vincent Bernardoff committed Sep 12, 2012
Showing with 19 additions and 13 deletions.
  1. +9 −6 src/client.ml
  2. +1 −1 src/client.mli
  3. +9 −6 src/opam.ml
View
15 src/client.ml
@@ -2069,7 +2069,7 @@ let config request =
log "OUTPUT: %S" output;
Globals.msg "%s\n" output
-let remote action =
+let remote ?(verbose=false) action =
log "remote %s" (string_of_remote action);
let t = load_state () in
let repos = File.Config.repositories t.config in
@@ -2102,12 +2102,15 @@ let remote action =
Dirname.rmdir (Path.R.root (Path.R.create repo)) in
match action with
| List ->
- let pretty_print r =
+ let pretty_print r =
+ if verbose then
Globals.msg "%-7s %10s %s\n"
(Printf.sprintf "[%s]" (Repository.kind r))
(Repository.name r)
- (Dirname.to_string (Repository.address r)) in
- List.iter pretty_print repos
+ (Dirname.to_string (Repository.address r))
+ else
+ Globals.msg "%s\n" (Repository.name r) in
+ List.iter pretty_print repos
| Add repo ->
let name = Repository.name repo in
if List.exists (fun r -> Repository.name r = name) repos then
@@ -2334,8 +2337,8 @@ let upload u r =
let remove name =
check (Write_lock (fun () -> remove name))
-let remote action =
- check (Write_lock (fun () -> remote action))
+let remote ?(verbose=false) action =
+ check (Write_lock (fun () -> remote ~verbose action))
let compiler_install quiet alias ocaml_version =
check (Write_lock (fun () -> compiler_install quiet alias ocaml_version))
View
2 src/client.mli
@@ -61,7 +61,7 @@ val upload : upload -> string option -> unit
val remove : N.Set.t -> unit
(** Manage remote repositories. Take the global file lock. *)
-val remote : remote -> unit
+val remote : ?verbose:bool -> remote -> unit
(** Install the given compiler. Take the global file lock. *)
val compiler_install: bool -> Alias.t -> OCaml_V.t -> unit
View
15 src/opam.ml
@@ -336,6 +336,7 @@ let remove = {
(* opam remote [-list|-add <url>|-rm <url>] *)
let remote =
let kind = ref None in
+ let verbose = ref false in
let command : [`add|`list|`rm] option ref = ref None in
let set c () = command := Some c in
{
@@ -344,21 +345,23 @@ let remote =
synopsis = "Manage remote servers";
help = "";
specs = [
+ ("-v" , Arg.Unit (fun () -> verbose := true), " Be verbose");
("-list" , Arg.Unit (set `list), " List the repositories");
("-add" , Arg.Unit (set `add) , " Add a new repository");
("-rm" , Arg.Unit (set `rm) , " Remove a remote repository");
("-kind" , Arg.String (fun s -> kind := Some s) , " (optional) Specify the repository kind");
];
anon;
main = parse_args (fun args ->
+ let verbose = !verbose in
match !command, args with
- | Some `list, [] -> Client.remote List
- | Some `rm, [ name ] -> Client.remote (Rm name)
- | Some `add , [ name; address ] ->
+ | Some `list, [] -> Client.remote ~verbose List
+ | Some `rm, [ name ] -> Client.remote ~verbose (Rm name)
+ | Some `add , [ name; address ] ->
let kind = guess_repository_kind !kind address in
- Client.remote (Add (Repository.create ~name ~kind ~address))
- | None, _ -> bad_argument "remote" "Command missing [-list|-add|-rm]"
- | _ -> bad_argument "remote" "Wrong arguments")
+ Client.remote ~verbose (Add (Repository.create ~name ~kind ~address))
+ | _ -> Client.remote ~verbose List
+ )
}
(* opam switch [-clone] OVERSION *)

0 comments on commit 05001d9

Please sign in to comment.
Something went wrong with that request. Please try again.