Skip to content

Commit 1af0ce4

Browse files
author
Guy Acosta
committed
Adds arg to supress auto opening of browser for html output. Issue for docker.
1 parent 0a37f3b commit 1af0ce4

File tree

6 files changed

+21
-7
lines changed

6 files changed

+21
-7
lines changed

AppInspector/AppInspector.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@
1414
<PackageId>ApplicationInspector</PackageId>
1515
<Product>Application Inspector</Product>
1616
<Authors>Microsoft</Authors>
17-
<Version>1.0.26</Version>
17+
<Version>1.0.28</Version>
1818
<AssemblyName>AppInspector</AssemblyName>
1919
<RootNamespace>ApplicationInspector</RootNamespace>
2020
<StartupObject>Microsoft.AppInspector.Program</StartupObject>
2121
<Company>Microsoft</Company>
2222
<SignAssembly>true</SignAssembly>
23-
<AssemblyVersion>1.0.26.0</AssemblyVersion>
24-
<FileVersion>1.0.26.0</FileVersion>
23+
<AssemblyVersion>1.0.28.0</AssemblyVersion>
24+
<FileVersion>1.0.28.0</FileVersion>
2525
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
2626
</PropertyGroup>
2727

AppInspector/AppMetaData.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ public class AppProfile
4949
public bool SimpleTagsOnly { get; set; }
5050
[JsonIgnore]
5151
public bool UniqueTagsOnly { get; }
52+
[JsonIgnore]
53+
public bool AutoBrowserOpen { get; set; }
5254

5355

5456
/// <summary>
@@ -59,7 +61,7 @@ public class AppProfile
5961
/// <param name="excludeRollup">omit aggregated rollup e.g. simple output with matches</param>
6062
/// <param name="simpleTagsOnly">simple output override</param>
6163
/// <param name="uniqueTagsOnly">avoid duplicate tag reporting</param>
62-
public AppProfile(string sourcePath, List<string> rulePaths, bool excludeRollup, bool simpleTagsOnly, bool uniqueTagsOnly)
64+
public AppProfile(string sourcePath, List<string> rulePaths, bool excludeRollup, bool simpleTagsOnly, bool uniqueTagsOnly, bool autoOpenBrowser=true)
6365
{
6466
SourcePath = sourcePath;
6567
Version = Program.GetVersion();
@@ -76,6 +78,7 @@ public AppProfile(string sourcePath, List<string> rulePaths, bool excludeRollup,
7678
ExcludeRollup = excludeRollup;
7779
SimpleTagsOnly = simpleTagsOnly;
7880
UniqueTagsOnly = uniqueTagsOnly;
81+
AutoBrowserOpen = autoOpenBrowser;
7982

8083
MetaData = new AppMetaData(sourcePath, rulePaths)
8184
{

AppInspector/Commands/AnalyzeCommand.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ public DateTime LastUpdated
6161
private string _arg_customRulesPath;
6262
private bool _arg_ignoreDefaultRules;
6363
private bool _arg_outputUniqueTagsOnly;
64+
private bool _arg_autoBrowserOpen;
6465
private string _arg_confidenceFilters;
6566
private bool _arg_simpleTagsOnly;
6667
private Confidence _arg_confidence;
@@ -79,6 +80,7 @@ public AnalyzeCommand(AnalyzeCommandOptions opts)
7980
_arg_outputUniqueTagsOnly = !opts.AllowDupTags;
8081
_arg_customRulesPath = opts.CustomRulesPath;
8182
_arg_confidenceFilters = opts.ConfidenceFilters;
83+
_arg_autoBrowserOpen = !opts.AutoBrowserOpen;
8284
_arg_ignoreDefaultRules = opts.IgnoreDefaultRules;
8385
_arg_simpleTagsOnly = opts.SimpleTagsOnly;
8486

@@ -185,7 +187,7 @@ void ConfigRules()
185187
}
186188
}
187189

188-
_appProfile = new AppProfile(_arg_sourcePath, rulePaths, false, _arg_simpleTagsOnly, _arg_outputUniqueTagsOnly);
190+
_appProfile = new AppProfile(_arg_sourcePath, rulePaths, false, _arg_simpleTagsOnly, _arg_outputUniqueTagsOnly, _arg_autoBrowserOpen);
189191
_appProfile.Args = "analyze -f " + _arg_fileFormat + " -u " + _arg_outputUniqueTagsOnly.ToString().ToLower() + " -v " +
190192
WriteOnce.Verbosity.ToString() + " -x " + _arg_confidence + " -i " + _arg_ignoreDefaultRules.ToString().ToLower();
191193
}
@@ -289,7 +291,11 @@ public int Run()
289291
else if (_appProfile.MatchList.Count == 0)
290292
WriteOnce.Error(ErrMsg.GetString(ErrMsg.ID.ANALYZE_NOPATTERNS));
291293
else
294+
{
292295
WriteOnce.Operation(ErrMsg.FormatString(ErrMsg.ID.CMD_COMPLETED, "Analyze"));
296+
if (!_arg_autoBrowserOpen)
297+
WriteOnce.Any(ErrMsg.FormatString(ErrMsg.ID.ANALYZE_OUTPUT_FILE, "output.html"));
298+
}
293299

294300
return _appProfile.MatchList.Count() == 0 ? (int)ExitCode.NoMatches :
295301
(int)ExitCode.MatchesFound;

AppInspector/Program.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ public class AnalyzeCommandOptions
4646
[Option('d', "allow-dup-tags", Required = false, HelpText = "Output contains unique and non-unique tag matches", Default = false)]
4747
public bool AllowDupTags { get; set; }
4848

49+
[Option('b', "supress-browser-open", Required = false, HelpText = "HTML formatted output is automatically opened to default browser", Default = false)]
50+
public bool AutoBrowserOpen { get; set; }
51+
4952
[Option('c', "confidence-filters", Required = false, HelpText = "Output only matches with specified confidence <value>,<value> [high|medium|low]", Default = "high,medium")]
5053
public string ConfidenceFilters { get; set; }
5154

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"profiles": {
33
"ApplicationInspector": {
4-
"commandName": "Project"
4+
"commandName": "Project",
5+
"commandLineArgs": "analyze -s c:\\temp\\main.cpp -b"
56
}
67
}
78
}

AppInspector/Writers/LiquidWriter.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ public override void WriteApp(AppProfile app)
8383
WriteOnce.Info(ErrMsg.GetString(ErrMsg.ID.ANALYZE_REPORTSIZE_WARN));
8484
}
8585

86-
Utils.OpenBrowser(htmlOutputFilePath);
86+
if (app.AutoBrowserOpen)
87+
Utils.OpenBrowser(htmlOutputFilePath);
8788
}
8889

8990

0 commit comments

Comments
 (0)