Skip to content

Commit ecf9fd6

Browse files
committed
simplify & dedup default values for argument parsing
1 parent f4bec38 commit ecf9fd6

File tree

1 file changed

+11
-22
lines changed

1 file changed

+11
-22
lines changed

source/ddox/main.d

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -111,33 +111,31 @@ int cmdServeTest(string[] args)
111111

112112
int setupGeneratorInput(ref string[] args, out GeneratorSettings gensettings, out Package pack)
113113
{
114+
gensettings = new GeneratorSettings;
115+
auto docsettings = new DdoxSettings;
116+
114117
string[] macrofiles;
115118
string[] overridemacrofiles;
116-
NavigationType navtype = NavigationType.ModuleTree;
117-
string[] pack_order;
118119
string sitemapurl = "http://127.0.0.1/";
119-
MethodStyle file_name_style = MethodStyle.unaltered;
120-
SortMode modsort = SortMode.protectionName;
121-
SortMode declsort = SortMode.protectionInheritanceName;
122120
bool lowercasenames;
123121
bool hyphenate;
124-
bool singlepageenum;
125122
getopt(args,
126123
//config.passThrough,
127-
"decl-sort", &declsort,
128-
"file-name-style", &file_name_style,
124+
"decl-sort", &docsettings.declSort,
125+
"file-name-style", &gensettings.fileNameStyle,
129126
"hyphenate", &hyphenate,
130127
"lowercase-names", &lowercasenames,
131-
"module-sort", &modsort,
132-
"navigation-type", &navtype,
128+
"module-sort", &docsettings.moduleSort,
129+
"navigation-type", &gensettings.navigationType,
133130
"override-macros", &overridemacrofiles,
134-
"package-order", &pack_order,
131+
"package-order", &docsettings.packageOrder,
135132
"sitemap-url", &sitemapurl,
136133
"std-macros", &macrofiles,
137-
"enum-member-pages", &singlepageenum,
134+
"enum-member-pages", &gensettings.enumMemberPages,
138135
);
136+
gensettings.siteUrl = URL(sitemapurl);
139137

140-
if (lowercasenames) file_name_style = MethodStyle.lowerCase;
138+
if (lowercasenames) gensettings.fileNameStyle = MethodStyle.lowerCase;
141139

142140
if( args.length < 3 ){
143141
showUsage(args);
@@ -149,17 +147,8 @@ int setupGeneratorInput(ref string[] args, out GeneratorSettings gensettings, ou
149147
if (hyphenate) enableHyphenation();
150148

151149
// parse the json output file
152-
auto docsettings = new DdoxSettings;
153-
docsettings.packageOrder = pack_order;
154-
docsettings.moduleSort = modsort;
155-
docsettings.declSort = declsort;
156150
pack = parseDocFile(args[2], docsettings);
157151

158-
gensettings = new GeneratorSettings;
159-
gensettings.siteUrl = URL(sitemapurl);
160-
gensettings.navigationType = navtype;
161-
gensettings.fileNameStyle = file_name_style;
162-
gensettings.enumMemberPages = singlepageenum;
163152
return 0;
164153
}
165154

0 commit comments

Comments
 (0)