Skip to content
Snippets Groups Projects
Commit b1bf334f authored by erwan's avatar erwan
Browse files

Chore: re-phrase the help messages

parent a622266e
No related branches found
No related tags found
No related merge requests found
Pipeline #35951 passed
...@@ -18,7 +18,9 @@ type t = { ...@@ -18,7 +18,9 @@ type t = {
} }
let usage_msg tool = let usage_msg tool =
("usage: " ^ tool ^ " <algoFiles>... <file> [-o <file>]\n" ) ("usage: " ^ tool ^ " \"<decoration pattern>\" <input-file.dot> [option]*
decorates an <input-file.dot> using a <decoration pattern>.
" )
let print_usage tool = Printf.printf "\n%s use -h for additional information.\n\n" (usage_msg tool); flush stdout; exit 1 let print_usage tool = Printf.printf "\n%s use -h for additional information.\n\n" (usage_msg tool); flush stdout; exit 1
...@@ -78,28 +80,27 @@ let printSpec args outChannel (c, messageList) = ( ...@@ -78,28 +80,27 @@ let printSpec args outChannel (c, messageList) = (
let help args tool = ( let help args tool = (
Printf.printf "\n"; Printf.printf "\n";
Printf.printf "%s" (usage_msg tool); Printf.printf "%s" (usage_msg tool);
Printf.printf "\n"; Printf.printf "
Printf.printf "Add or replace the 'algo' label in the dot file, to change the algorithms attached to each node.\n"; <decoration pattern> specify which algos should be attached to which nodes.
Printf.printf "<file> is the dot file on which you wish to change the algo.\n"; Nodes ids are supposed to be consecutive strictly positive integers.
Printf.printf "<algo-files> describe which nodes will have which algo attached to them. The syntax is the following :\n"; The <decoration pattern> syntax (in EBNF) is:
Printf.printf "\n"; <decoration pattern> ::= <deco><more>
Printf.printf " - To assign a file (containing an algo) to one node, write 'i:file', 'i' being the index of the node\n"; <deco> ::=
Printf.printf " and 'file' being the file of the algo. \n"; | <int>:<string>
Printf.printf "\n"; | <int>-<int>:<string>
Printf.printf " - To assign a file to multiple nodes, write 'i-j:file', with 'i' being the index of the first node,\n"; | <int>-:<string>
Printf.printf " 'j' being the last node's index (included) and 'file' being the file of the algo. \n"; <more> ::= ([ \\t]*<deco>)*
Printf.printf " Note : write 'i-:file' to assign the file to all nodes from i.\n";
Printf.printf "\n"; \"i:file\" attaches <file> to node <i>
Printf.printf " - Concatenate all the the descriptions, with a whitespace between each.\n"; \"i-j:file\" attaches <file> to nodes <i>, <i>+1, ..., <j>
Printf.printf " Example : \"1:root.ml 2-:p.ml\" assign root.ml to the first node, and p.ml to the other ones.\n"; \"i-:file\" attaches <file> to nodes <i>, <i>+1, ..., <the last node>
(* maybe I should change it such that it accepts with or without the double quotes *)
Printf.printf "\n"; Example: the decoration pattern \"1:root.ml 2-:p.ml\" assigns
Printf.printf "\n"; \"root.ml\" to the first node, and \"p.ml\" to the other ones.
Printf.printf "============ Available Options ============\n\n";
( [option] are:
List.iter (printSpec args stdout) (List.rev args._general_man) ";
); List.iter (printSpec args stdout) (List.rev args._general_man);
Printf.printf "\n";
exit 0 exit 0
) )
...@@ -114,15 +115,13 @@ let mkopt : t -> string list -> ?arg:string -> Arg.spec -> (string list -> unit) ...@@ -114,15 +115,13 @@ let mkopt : t -> string list -> ?arg:string -> Arg.spec -> (string list -> unit)
(*** User Options Tab **) (*** User Options Tab **)
let (mkoptab : string array -> t -> unit) = let (mkoptab : string array -> t -> unit) =
fun argv args -> ( fun argv args -> (
mkopt args ["--output";"-o"] ~arg:" <file>" mkopt args ["--output";"-o"] ~arg:" <file>"
(Arg.String (fun s -> args.output <- s)) (Arg.String (fun s -> args.output <- s))
["Set the output file to the given file.\n"]; ["Redirect stdout into a <file>"];
mkopt args ["--help";"-h"] mkopt args ["--help";"-h"]
(Arg.Unit (fun () -> help args argv.(0) )) (Arg.Unit (fun () -> help args argv.(0) ))
["Prints this help\n"]; ["Print this help\n"];
) )
(* all unrecognized options are accumulated *) (* all unrecognized options are accumulated *)
...@@ -136,38 +135,39 @@ let parse_file_spec : (string list -> files_spec_t list) = ...@@ -136,38 +135,39 @@ let parse_file_spec : (string list -> files_spec_t list) =
fun s -> fun s ->
List.map List.map
(fun file -> (fun file ->
try ( try (
Scanf.sscanf file "%[-0-9]:%s" Scanf.sscanf file "%[-0-9]:%s"
(fun range file -> (fun range file ->
if range = "" then if range = "" then
raise (Invalid_file_spec raise (Invalid_file_spec
(file, "The first and last node's indexes are missing")) (file, "The first and last node's indexes are \
else missing"))
Scanf.sscanf range "%d%s" else
(fun a s -> Scanf.sscanf range "%d%s"
if (a < 0) then (fun a s ->
raise (Invalid_file_spec if (a < 0) then
(file,"The first node's index have to be positive or null")) else raise (Invalid_file_spec
if (s = "") then (a,a,file) else (file,"The first node's index have to be positive or null")) else
if (s = "-") then (a,-1,file) else if (s = "") then (a,a,file) else
Scanf.sscanf s "-%d" (fun b -> if (s = "-") then (a,-1,file) else
if (b < a) then Scanf.sscanf s "-%d" (fun b ->
raise if (b < a) then
(Invalid_file_spec raise
(file, (Invalid_file_spec
"The last node's index have to be higher than the first node's index")) (file,
else "The last node's index have to be higher than the first node's index"))
(a,b,file) else
) (a,b,file)
) )
) )
) )
with )
| Scanf.Scan_failure _ -> with
| Scanf.Scan_failure _ ->
raise ( raise (
Invalid_file_spec ( Invalid_file_spec (
file, file,
"The boundaries (first and last node's indexes) should be integers, but an non-numerical character has been found")) "The boundaries (first and last node's indexes) should be integers, but an non-numerical character has been found"))
) s ) s
let rec pop l = (* last ? *) let rec pop l = (* last ? *)
......
...@@ -42,53 +42,54 @@ type t = { ...@@ -42,53 +42,54 @@ type t = {
mutable _margin : int; mutable _margin : int;
} }
let usage_msg do_print_command tool = let usage_msg do_print_command tool =
if do_print_command then "gg is an experimental graph generator.\n"^
(if do_print_command then
("usage: " ^ tool ^ " <command> [options]\n") ("usage: " ^ tool ^ " <command> [options]\n")
else else
("usage: "^tool^" [options]\n") ("usage: "^tool^" [options]\n"))
let print_usage output do_print_command tool = let print_usage output do_print_command tool =
Printf.fprintf output "%s%s" (usage_msg do_print_command tool) ( Printf.fprintf output "%s%s" (usage_msg do_print_command tool) (
if (do_print_command) then if (do_print_command) then
"use -h to see the available commands.\n\n" "use -h to see the available commands.\n\n"
else "use -h to see available options.\n" else "use -h to see available options.\n"
) )
let (make_args : unit -> t) = let (make_args : unit -> t) =
fun () -> fun () ->
{ {
outputFile = ""; outputFile = "";
dotUDG = ""; dotUDG = "";
dotUDGrad = ""; dotUDGrad = "";
action = "void"; action = "void";
n = -1; n = -1;
grid = { grid = {
width = 0; width = 0;
height = 0; height = 0;
}; };
er = 0.3; er = 0.3;
ba = 2; ba = 2;
qudg = { qudg = {
width = 10.; width = 10.;
height = 10.; height = 10.;
radius = 3.; radius = 3.;
r1 = 2.; r1 = 2.;
p = 0.5; p = 0.5;
}; };
attr = []; attr = [];
silent = false; silent = false;
directed = false; directed = false;
_args = []; _args = [];
_man = []; _man = [];
_others = []; _others = [];
_margin = 12; _margin = 12;
} }
let first_line b = ( let first_line b = (
try ( try (
......
Some experimental but yet useful tools by Nathan Rébiscoul and Gwennan
Eliezer (undergraduate trainees).
- =gg= is a dot graph generator.
- =gg-deco= decorates graphs generated by =gg=
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment