From 0ad6a4faf3121a4a19b62155604f34d220281d04 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Fri, 25 Jan 2019 20:29:59 -0500 Subject: getopt --- org/doc_reform.org | 112 +++++++++++++++++--------------------------- src/doc_reform/doc_reform.d | 112 +++++++++++++++++--------------------------- 2 files changed, 88 insertions(+), 136 deletions(-) diff --git a/org/doc_reform.org b/org/doc_reform.org index 80e703b..9be2480 100644 --- a/org/doc_reform.org +++ b/org/doc_reform.org @@ -257,10 +257,11 @@ bool[string] opts = [ "light" : false, "manifest" : false, "ocn" : true, - "parallelise" : true, - "parallelise-subprocesses" : false, + "parallel" : false, + "parallel-subprocesses" : false, "quiet" : false, "pod" : false, + "serial" : false, "source" : false, "sqlite-discrete" : false, "sqlite-db-create" : false, @@ -271,7 +272,7 @@ bool[string] opts = [ "sqlite-update" : false, "text" : false, "verbose" : false, - "very-verbose" : false, + "very-verbose" : false, "xhtml" : false, "section_toc" : true, "section_body" : true, @@ -307,10 +308,11 @@ auto helpInfo = getopt(args, "light", "--light default light theme", &opts["light"], "manifest", "--manifest process manifest output", &opts["manifest"], "ocn", "--ocn object cite numbers (default)", &opts["ocn"], - "parallelise", "--parallelise parallelisation", &opts["parallelise"], - "parallelise-subprocesses", "--parallelise-subprocesses nested parallelisation", &opts["parallelise-subprocesses"], + "parallel", "--parallel parallelisation", &opts["parallel"], + "parallel-subprocesses", "--parallel-subprocesses nested parallelisation", &opts["parallel-subprocesses"], "quiet", "--quiet output to terminal", &opts["quiet"], "pod", "--pod doc reform pod source content bundled", &opts["pod"], + "serial", "--serial serial processing", &opts["serial"], "source", "--source markup source text content", &opts["source"], "sqlite-discrete", "--sqlite process discrete sqlite output", &opts["sqlite-discrete"], "sqlite-db-create", "--sqlite-db-create create db, create tables", &opts["sqlite-db-create"], @@ -380,41 +382,27 @@ struct OptActions { return opts["epub"]; } auto html() { - bool _is = ( - opts["html"] - || opts["html-seg"] - || opts["html-scroll"] - ) - ? true - : false; + bool _is; + if ( opts["html"] || opts["html-seg"] || opts["html-scroll"]) + { _is = true; } else { _is = false; } return _is; } auto html_seg() { - bool _is = ( - opts["html"] - || opts["html-seg"] - ) - ? true - : false; + bool _is; + if ( opts["html"] || opts["html-seg"]) + { _is = true; } else { _is = false; } return _is; } auto html_scroll() { - bool _is = ( - opts["html"] - || opts["html-scroll"] - ) - ? true - : false; + bool _is; + if ( opts["html"] || opts["html-scroll"]) + { _is = true; } else { _is = false; } return _is; } auto html_stuff() { - bool _is = ( - opts["html"] - || opts["html-scroll"] - || opts["html-seg"] - ) - ? true - : false; + bool _is; + if (opts["html"] || opts["html-scroll"] || opts["html-seg"]) + { _is = true; } else { _is = false; } return _is; } auto manifest() { @@ -436,57 +424,43 @@ struct OptActions { return opts["sqlite-discrete"]; } auto sqlite_db_drop() { - bool _is = ( - opts["sqlite-db-recreate"] - || opts["sqlite-db-drop"] - ) - ? true - : false; + bool _is; + if ( opts["sqlite-db-recreate"] || opts["sqlite-db-drop"]) + { _is = true; } else { _is = false; } return _is; } auto sqlite_db_create() { - bool _is = ( - opts["sqlite-db-recreate"] - || opts["sqlite-db-create"] - ) - ? true - : false; + bool _is; + if ( opts["sqlite-db-recreate"] || opts["sqlite-db-create"]) + { _is = true; } else { _is = false; } return _is; } auto sqlite_delete() { return opts["sqlite-delete"]; } auto sqlite_update() { - bool _is = ( - opts["sqlite-update"] - || opts["sqlite-insert"] - ) - ? true - : false; + bool _is; + if (opts["sqlite-update"] || opts["sqlite-insert"]) + { _is = true; } else { _is = false; } return _is; } auto sqlite_shared_db_action() { - bool _is = ( - opts["sqlite-db-recreate"] + bool _is; + if (opts["sqlite-db-recreate"] || opts["sqlite-db-create"] || opts["sqlite-delete"] || opts["sqlite-insert"] || opts["sqlite-update"] - ) - ? true - : false; + ) { _is = true; } else { _is = false; } return _is; } auto text() { return opts["text"]; } auto verbose() { - bool _is = ( - opts["verbose"] - || opts["very-verbose"] - ) - ? true - : false; + bool _is; + if (opts["verbose"] || opts["very-verbose"]) + { _is = true; } else { _is = false; } return _is; } auto very_verbose() { @@ -535,12 +509,16 @@ struct OptActions { return settings["sqlite-filename"]; } auto parallelise() { - bool _is = ( opts["parallelise"]) ? true : false; - _is = ( sqlite_shared_db_action ) ? false : true; + bool _is; + if (opts["parallel"] == true + || (opts["parallel"] != false && opts["serial"] == false)) { + _is = true; + if (sqlite_shared_db_action) { _is = false; } + } else { _is = false; } return _is; } auto parallelise_subprocesses() { - return opts["parallelise-subprocesses"]; + return opts["parallel-subprocesses"]; } auto output_task_scheduler() { int[] schedule; @@ -568,8 +546,8 @@ struct OptActions { return schedule.sort().uniq; } auto abstraction() { - bool _is = ( - opts["abstraction"] + bool _is; + if (opts["abstraction"] || concordance || epub || html @@ -579,9 +557,7 @@ struct OptActions { || sqlite_discrete || sqlite_delete || sqlite_update - ) - ? true - : false; + ) { _is = true; } else { _is = false; } return _is; } } diff --git a/src/doc_reform/doc_reform.d b/src/doc_reform/doc_reform.d index b59743c..fc93a6c 100755 --- a/src/doc_reform/doc_reform.d +++ b/src/doc_reform/doc_reform.d @@ -73,10 +73,11 @@ void main(string[] args) { "light" : false, "manifest" : false, "ocn" : true, - "parallelise" : true, - "parallelise-subprocesses" : false, + "parallel" : false, + "parallel-subprocesses" : false, "quiet" : false, "pod" : false, + "serial" : false, "source" : false, "sqlite-discrete" : false, "sqlite-db-create" : false, @@ -87,7 +88,7 @@ void main(string[] args) { "sqlite-update" : false, "text" : false, "verbose" : false, - "very-verbose" : false, + "very-verbose" : false, "xhtml" : false, "section_toc" : true, "section_body" : true, @@ -123,10 +124,11 @@ void main(string[] args) { "light", "--light default light theme", &opts["light"], "manifest", "--manifest process manifest output", &opts["manifest"], "ocn", "--ocn object cite numbers (default)", &opts["ocn"], - "parallelise", "--parallelise parallelisation", &opts["parallelise"], - "parallelise-subprocesses", "--parallelise-subprocesses nested parallelisation", &opts["parallelise-subprocesses"], + "parallel", "--parallel parallelisation", &opts["parallel"], + "parallel-subprocesses", "--parallel-subprocesses nested parallelisation", &opts["parallel-subprocesses"], "quiet", "--quiet output to terminal", &opts["quiet"], "pod", "--pod doc reform pod source content bundled", &opts["pod"], + "serial", "--serial serial processing", &opts["serial"], "source", "--source markup source text content", &opts["source"], "sqlite-discrete", "--sqlite process discrete sqlite output", &opts["sqlite-discrete"], "sqlite-db-create", "--sqlite-db-create create db, create tables", &opts["sqlite-db-create"], @@ -189,41 +191,27 @@ void main(string[] args) { return opts["epub"]; } auto html() { - bool _is = ( - opts["html"] - || opts["html-seg"] - || opts["html-scroll"] - ) - ? true - : false; + bool _is; + if ( opts["html"] || opts["html-seg"] || opts["html-scroll"]) + { _is = true; } else { _is = false; } return _is; } auto html_seg() { - bool _is = ( - opts["html"] - || opts["html-seg"] - ) - ? true - : false; + bool _is; + if ( opts["html"] || opts["html-seg"]) + { _is = true; } else { _is = false; } return _is; } auto html_scroll() { - bool _is = ( - opts["html"] - || opts["html-scroll"] - ) - ? true - : false; + bool _is; + if ( opts["html"] || opts["html-scroll"]) + { _is = true; } else { _is = false; } return _is; } auto html_stuff() { - bool _is = ( - opts["html"] - || opts["html-scroll"] - || opts["html-seg"] - ) - ? true - : false; + bool _is; + if (opts["html"] || opts["html-scroll"] || opts["html-seg"]) + { _is = true; } else { _is = false; } return _is; } auto manifest() { @@ -245,57 +233,43 @@ void main(string[] args) { return opts["sqlite-discrete"]; } auto sqlite_db_drop() { - bool _is = ( - opts["sqlite-db-recreate"] - || opts["sqlite-db-drop"] - ) - ? true - : false; + bool _is; + if ( opts["sqlite-db-recreate"] || opts["sqlite-db-drop"]) + { _is = true; } else { _is = false; } return _is; } auto sqlite_db_create() { - bool _is = ( - opts["sqlite-db-recreate"] - || opts["sqlite-db-create"] - ) - ? true - : false; + bool _is; + if ( opts["sqlite-db-recreate"] || opts["sqlite-db-create"]) + { _is = true; } else { _is = false; } return _is; } auto sqlite_delete() { return opts["sqlite-delete"]; } auto sqlite_update() { - bool _is = ( - opts["sqlite-update"] - || opts["sqlite-insert"] - ) - ? true - : false; + bool _is; + if (opts["sqlite-update"] || opts["sqlite-insert"]) + { _is = true; } else { _is = false; } return _is; } auto sqlite_shared_db_action() { - bool _is = ( - opts["sqlite-db-recreate"] + bool _is; + if (opts["sqlite-db-recreate"] || opts["sqlite-db-create"] || opts["sqlite-delete"] || opts["sqlite-insert"] || opts["sqlite-update"] - ) - ? true - : false; + ) { _is = true; } else { _is = false; } return _is; } auto text() { return opts["text"]; } auto verbose() { - bool _is = ( - opts["verbose"] - || opts["very-verbose"] - ) - ? true - : false; + bool _is; + if (opts["verbose"] || opts["very-verbose"]) + { _is = true; } else { _is = false; } return _is; } auto very_verbose() { @@ -344,12 +318,16 @@ void main(string[] args) { return settings["sqlite-filename"]; } auto parallelise() { - bool _is = ( opts["parallelise"]) ? true : false; - _is = ( sqlite_shared_db_action ) ? false : true; + bool _is; + if (opts["parallel"] == true + || (opts["parallel"] != false && opts["serial"] == false)) { + _is = true; + if (sqlite_shared_db_action) { _is = false; } + } else { _is = false; } return _is; } auto parallelise_subprocesses() { - return opts["parallelise-subprocesses"]; + return opts["parallel-subprocesses"]; } auto output_task_scheduler() { int[] schedule; @@ -377,8 +355,8 @@ void main(string[] args) { return schedule.sort().uniq; } auto abstraction() { - bool _is = ( - opts["abstraction"] + bool _is; + if (opts["abstraction"] || concordance || epub || html @@ -388,9 +366,7 @@ void main(string[] args) { || sqlite_discrete || sqlite_delete || sqlite_update - ) - ? true - : false; + ) { _is = true; } else { _is = false; } return _is; } } -- cgit v1.2.3