File tree Expand file tree Collapse file tree 4 files changed +20
-3
lines changed
Expand file tree Collapse file tree 4 files changed +20
-3
lines changed Original file line number Diff line number Diff line change 11[
22 {
3- "description" : " Default AWS EC2 Instance hours (according to ChatGPT) " ,
3+ "description" : " Default AWS EC2 Instance hours" ,
44 "match_query" : " type = aws_instance and service_class = instance and purchase_option = on_demand and os = linux" ,
55 "usage" : {
66 "time" : 730
Original file line number Diff line number Diff line change @@ -115,3 +115,5 @@ let of_channel in_chan =
115115
116116let match_ ms t =
117117 CCList. find_opt (fun { Entry. match_query; _ } -> Oiq_match_query. eval ms match_query) t.entries
118+
119+ let to_yojson { entries } = [% to_yojson: Entry. t list ] entries
Original file line number Diff line number Diff line change @@ -63,7 +63,7 @@ module Entry : sig
6363end
6464
6565type of_channel_err = [ `Usage_file_err of string ] [@@ deriving show ]
66- type t
66+ type t [@@deriving to_yojson]
6767
6868val default : unit -> t
6969val of_channel : in_channel -> (t , [> of_channel_err ]) result
Original file line number Diff line number Diff line change @@ -70,6 +70,11 @@ module Cli = struct
7070 C.Cmd. v
7171 (C.Cmd. info " price" ~doc ~exits )
7272 C.Term. (const f $ usage $ input $ output_format $ match_query $ region)
73+
74+ let print_default_usage_cmd f =
75+ let doc = " Print default usage file." in
76+ let exits = C.Cmd.Exit. defaults in
77+ C.Cmd. v (C.Cmd. info " print-default-usage" ~doc ~exits ) C.Term. (const f $ const () )
7378end
7479
7580let reporter ppf =
@@ -153,6 +158,16 @@ let price usage input output_format match_query regions =
153158 Logs. err (fun m -> m " %a" Oiq. pp_price_err err);
154159 exit 1
155160
161+ let print_default_usage () =
162+ let default = Oiq_usage. default () in
163+ print_endline @@ Yojson.Safe. pretty_to_string @@ Oiq_usage. to_yojson default
164+
156165let () =
157166 let info = Cmdliner.Cmd. info ~version: Cli. version " oiq" in
158- exit @@ Cmdliner.Cmd. eval @@ Cmdliner.Cmd. group info [ Cli. match_cmd match_; Cli. price_cmd price ]
167+ exit
168+ @@ Cmdliner.Cmd. eval
169+ @@ Cmdliner.Cmd. group
170+ info
171+ [
172+ Cli. match_cmd match_; Cli. price_cmd price; Cli. print_default_usage_cmd print_default_usage;
173+ ]
You can’t perform that action at this time.
0 commit comments