1 module tagion.tools.collider.BehaviourOptions; 2 import std.array : array, join, split; 3 import std.process : environment, execute; 4 import tagion.basic.Types : FileExtension; 5 import tagion.utils.JSONCommon; 6 7 enum ONE_ARGS_ONLY = 2; 8 enum DFMT_ENV = "DFMT"; /// Set the path and argument d-format including the flags 9 enum ICONV = "iconv"; /// Character format converter 10 11 /** 12 * Option setting for the optarg and behaviour.json config file 13 */ 14 struct BehaviourOptions { 15 /** Include paths for the BDD source files */ 16 string[] paths; 17 /** BDD extension (default markdown .md) */ 18 string bdd_ext; 19 /** Extension for d-source files (default .d) */ 20 string d_ext; 21 /** Regex filter for the files to be incl */ 22 string regex_inc; 23 /** Regex for the files to be excluded */ 24 string regex_exc; 25 /** Extension for the generated BDD-files */ 26 string bdd_gen_ext; 27 /** D source formater (default dfmt) */ 28 string dfmt; 29 /** Command line flags for the dfmt */ 30 string[] dfmt_flags; 31 32 /** Character converter (default iconv) */ 33 string iconv; 34 /** Command line flags for the iconv */ 35 string[] iconv_flags; 36 37 string importfile; /// Import file which are included into the generated skeleton 38 bool enable_package; /// This produce the package 39 bool silent; 40 /** 41 * Used to set default options if config file not provided 42 */ 43 // string test_stage_env; 44 // string dbin_env; 45 string schedule_file; /// Schedule filename 46 string collider_root; 47 void setDefault() { 48 const gen = "gen"; 49 bdd_ext = FileExtension.markdown; 50 bdd_gen_ext = [gen, FileExtension.markdown].join; 51 d_ext = [gen, FileExtension.dsrc].join; 52 regex_inc = `/testbench/`; 53 // test_stage_env = "TEST_STAGE"; 54 if (!(DFMT_ENV in environment)) { 55 const which_dfmt = execute(["which", "dfmt"]); 56 if (which_dfmt.status is 0) { 57 dfmt = which_dfmt.output; 58 dfmt_flags = ["-i"]; 59 } 60 } 61 const which_iconv = execute(["which", "iconv"]); 62 iconv = which_iconv.output; 63 iconv_flags = ["-t", "utf-8", "-f", "utf-8", "-c"]; 64 // dbin_env = "DBIN"; 65 } 66 67 mixin JSONCommon; 68 mixin JSONConfig; 69 }