Skip to content

Commit

Permalink
opam init --dot-profile=FILE should pick as default config file giv…
Browse files Browse the repository at this point in the history
…en the one given by the user.
  • Loading branch information
samoht committed Mar 5, 2013
1 parent 7d184c9 commit 4908e07
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
8 changes: 4 additions & 4 deletions src/client/opamClient.ml
Original file line number Diff line number Diff line change
Expand Up @@ -651,16 +651,16 @@ module API = struct
wish_remove = [];
wish_upgrade = compiler_packages } in

let dot_profile = Some dot_profile in
let dot_profile_o = Some dot_profile in
begin match update_config with
| Some `ask -> OpamState.update_setup_interactive t ~global:true
| Some `ask -> OpamState.update_setup_interactive t ~global:true ~dot_profile
| Some (`sh|`zsh as shell) ->
let complete = Some shell in
let global = Some { complete; switch_eval = true } in
OpamState.update_setup t ~dot_profile ~ocamlinit:true ~global
OpamState.update_setup t ~dot_profile:dot_profile_o ~ocamlinit:true ~global
| None -> ()
end;
OpamState.print_env_warning t ~eval:false ~dot_profile
OpamState.print_env_warning t ~eval:false ~dot_profile:dot_profile_o

with e ->
if not !OpamGlobals.debug then
Expand Down
18 changes: 11 additions & 7 deletions src/client/opamState.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1083,7 +1083,7 @@ let display_setup t ~dot_profile =
OpamGlobals.msg "Global configuration:\n";
List.iter print global_setup

let update_setup_interactive t ~global =
let update_setup_interactive t ~global ~dot_profile =
let max = if not global then 2 else 4 in
let current = ref 1 in
let stats () =
Expand All @@ -1094,16 +1094,20 @@ let update_setup_interactive t ~global =
if confirm "Do you want to update your configuration to use OPAM ?" then (
let dot_profile =
let file =
match read "%sDo you want to update your shell configuration file ? [default: ~/.profile]" (stats ()) with
match
read "%sDo you want to update your shell configuration file ? [default: %s]"
(OpamFilename.prettify dot_profile)
(stats ())
with
| Some "y"
| Some "Y"
| None -> Filename.concat (OpamMisc.getenv "HOME") ".profile"
| Some s -> s in
if not (Sys.file_exists file)
&& not (confirm " %S does not exist, do you want to create it ?" file) then
| None -> dot_profile
| Some s -> OpamFilename.of_string s in
if not (OpamFilename.exists file)
&& not (confirm " %S does not exist, do you want to create it ?" (OpamFilename.to_string file)) then
None
else
Some (OpamFilename.of_string file) in
Some file in
let ocamlinit =
confirm "%sDo you want to update your ~/.ocamlinit ?" (stats ()) in
let complete =
Expand Down
2 changes: 1 addition & 1 deletion src/client/opamState.mli
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ val print_env_warning: state -> eval:bool -> dot_profile:filename option -> unit
(** {2 Initialisation} *)

(** Update the global and user configuration by asking some questions. *)
val update_setup_interactive: state -> global:bool -> unit
val update_setup_interactive: state -> global:bool -> dot_profile:filename -> unit

(** Display the global and user configuration for OPAM. *)
val display_setup: state -> dot_profile:filename -> unit
Expand Down

0 comments on commit 4908e07

Please sign in to comment.