Skip to content

Commit

Permalink
Merge pull request #70 from lequal/md-template
Browse files Browse the repository at this point in the history
Add option to change markdown template
  • Loading branch information
Sancretor authored Jun 5, 2019
2 parents 9715d7f + cb1ff98 commit 9439bbd
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ Generate editable reports for SonarQube projects.
-h,--help Display this message.
-l,--language <arg> Language of the report. Values: en_US, fr_FR. Default: en_US.
-m,--disable-markdown Disable markdown generation.
-n,--template-markdown <arg> Path to the report template in markdown. Default: usage of internal template.
-o,--output <arg> Output path for exported resources.
-p,--project <arg> SonarQube key of the targeted project.
-r,--template-report <arg> Path to the report template. Default: usage of internal template.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public static void report(final ReportConfiguration configuration, final Report
// Export in markdown if requested
if (configuration.isEnableMarkdown()) {
final String MDFilename = formatFilename(MD_FILENAME, configuration.getOutput(), model.getProjectName());
markdownExporter.export(model, MDFilename, model.getProjectName());
markdownExporter.export(model, MDFilename, configuration.getTemplateMarkdown());
}

// Export issues in report if requested
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public class CommandLineManager {
{"e", "disable-spreadsheet", Boolean.FALSE.toString(), "Disable spreadsheet generation."},
{"f", "disable-csv", Boolean.TRUE.toString(), "Disable CSV generation"},
{"m", "disable-markdown", Boolean.TRUE.toString(), "Disable Markdown generation"},
{"n", "template-markdown", Boolean.TRUE.toString(), "Path to the report template in markdown. Default: usage of internal template."},
{"r", "template-report", Boolean.TRUE.toString(), "Path to the report template. Default: usage of internal template."},
{"x", "template-spreadsheet", Boolean.TRUE.toString(), "Path to the spreadsheet template. Default: usage of internal template."}
};
Expand Down
13 changes: 10 additions & 3 deletions src/main/java/fr/cnes/sonar/report/utils/ReportConfiguration.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ public class ReportConfiguration {
private String templateReport;
/** Options for x. */
private String templateSpreadsheet;
/** Options for n. */
private String templateMarkdown;

/**
* Private constructor, use create method instead.
Expand All @@ -81,7 +83,7 @@ private ReportConfiguration(final boolean help, final boolean version, final Str
final boolean enableConf, final boolean enableReport,
final boolean enableSpreadsheet, final boolean enableCSV,
final boolean enableMarkdown, String templateReport,
final String templateSpreadsheet) {
final String templateSpreadsheet, final String templateMarkdown) {
this.help = help;
this.version = version;
this.server = server;
Expand All @@ -98,6 +100,7 @@ private ReportConfiguration(final boolean help, final boolean version, final Str
this.enableMarkdown = enableMarkdown;
this.templateReport = templateReport;
this.templateSpreadsheet = templateSpreadsheet;
this.templateMarkdown = templateMarkdown;
}

/**
Expand Down Expand Up @@ -129,7 +132,8 @@ public static ReportConfiguration create(final String[] pArgs) {
!commandLineManager.hasOption("f"), // Why f? Because every "logic" options like "c" are already used
!commandLineManager.hasOption("m"),
commandLineManager.getOptionValue("r", StringManager.EMPTY),
commandLineManager.getOptionValue("x", StringManager.EMPTY));
commandLineManager.getOptionValue("x", StringManager.EMPTY),
commandLineManager.getOptionValue("n", StringManager.EMPTY));
}

public boolean isHelp() {
Expand Down Expand Up @@ -191,5 +195,8 @@ public String getTemplateReport() {
public String getTemplateSpreadsheet() {
return templateSpreadsheet;
}


public String getTemplateMarkdown(){
return templateMarkdown;
}
}

0 comments on commit 9439bbd

Please sign in to comment.