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