You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Using "console.WriteLine(url)" (lowercase c) would insert newlines at the physical console length, making the written URL neither copyable nor clickable
55
-
// At that point the status has terminated so it's fine not using the IAnsiConsole methods
56
-
awaitstdOut.WriteLineAsync(url);
57
-
if(!settings.NoBrowser)
54
+
if(settings.UrlAction.HasFlag(UrlAction.print))
55
+
{
56
+
// Using "console.WriteLine(url)" (lowercase c) would insert newlines at the physical console length, making the written URL neither copyable nor clickable
57
+
// At that point the status has terminated so it's fine not using the IAnsiConsole methods
Copy file name to clipboardExpand all lines: src/nugraph/GraphCommandSettings.cs
+45-25Lines changed: 45 additions & 25 deletions
Original file line number
Diff line number
Diff line change
@@ -12,6 +12,15 @@
12
12
13
13
namespacenugraph;
14
14
15
+
[Flags]
16
+
[SuppressMessage("ReSharper","InconsistentNaming",Justification="Better fit for command line options")]
17
+
publicenumUrlAction
18
+
{
19
+
none=0,
20
+
open=1<<0,
21
+
print=1<<1,
22
+
}
23
+
15
24
[SuppressMessage("ReSharper","AutoPropertyCanBeMadeGetOnly.Global",Justification="Required for Spectre.Console.Cli binding")]
16
25
[SuppressMessage("ReSharper","UnusedAutoPropertyAccessor.Global",Justification="Required for Spectre.Console.Cli binding")]
17
26
[SuppressMessage("ReSharper","ClassNeverInstantiated.Global",Justification="Instantiated by Spectre.Console.Cli through reflection")]
@@ -21,66 +30,77 @@ internal sealed class GraphCommandSettings : CommandSettings
21
30
publicconststringDefaultTitle="Dependency graph of [SOURCE]";
22
31
23
32
[CommandArgument(0,"[SOURCE]")]
24
-
[Description("The source of the graph. Can be either a directory containing a .NET project, a .NET project file (csproj/fsproj/vbproj) or the name of a NuGet package, "+
25
-
"optionally with a specific version, e.g. [b]Newtonsoft.Json/13.0.3[/].")]
33
+
[Description("The source of the graph\n"+
34
+
"Can be either\n"+
35
+
" * the name of a NuGet package, optionally with a specific version, e.g. [b]Newtonsoft.Json/13.0.3[/]\n"+
36
+
" * a .NET project file (csproj/fsproj/vbproj)\n"+
37
+
" * a directory containing a single .NET project\n")]
26
38
publicstring?SourceInput{get;init;}
27
39
28
40
publicFileOrPackage?Source{get;privateset;}
29
41
30
-
[CommandOption("-o|--output <OUTPUT>")]
31
-
[Description("The path to the dependency graph output file. If not specified, the dependency graph URL is written on the standard output and an online service is opened in the default browser.")]
32
-
publicFileInfo?OutputFile{get;init;}
33
-
34
42
[CommandOption("-f|--framework <FRAMEWORK>")]
35
-
[Description("The target framework to consider when building the dependency graph.")]
43
+
[Description("The target framework to consider when building the dependency graph\n"+
44
+
"See https://learn.microsoft.com/en-us/dotnet/standard/frameworks#supported-target-frameworks for the list of supported target frameworks")]
[Description("The target runtime to consider when building the dependency graph.")]
49
+
[Description("The target runtime to consider when building the dependency graph\n"+
50
+
"See https://learn.microsoft.com/en-us/dotnet/core/rid-catalog#known-rids for the list of known runtime identifiers")]
41
51
publicstring?RuntimeIdentifier{get;init;}
42
52
53
+
[CommandOption("-o|--output <OUTPUT>")]
54
+
[Description("The path to the dependency graph output file\n"+
55
+
"A Mermaid diagram is written if the file name ends with either [b].mmd[/] or [b].mermaid[/], otherwise a Graphviz diagram is written\n"+
56
+
"If not specified, the default web browser is used to render the dependency graph using an online service\n"+
57
+
"See also the [b]--format[/] and [b]--url[/] options")]
58
+
publicFileInfo?OutputFile{get;init;}
59
+
43
60
[CommandOption("-m|--format <FORMAT>")]
44
-
[Description($"The format to use when the [b]--output[/] option is not specified.\n"+
61
+
[Description($"The format to use when the [b]--output[/] option is not specified\n"+
45
62
$"Use [b]mmd[/] or [b]mermaid[/] for Mermaid Live Editor https://mermaid.live\n"+
46
63
$"Use [b]dot[/], [b]gv[/] or [b]graphviz[/] for Edotor https://edotor.net\n"+
47
-
"See https://github.com/0xced/nugraph/#output for even more supported formats.")]
64
+
"See https://github.com/0xced/nugraph/#output for even more supported formats")]
48
65
[DefaultValue("mermaid")]
49
66
publicstringFormat{get;init;}="";
50
67
51
68
publicOnlineServiceService{get;privateset;}
52
69
70
+
[CommandOption("-u|--url")]
71
+
[Description("Defines what to do when the [b]--output[/] option is not specified\n"+
72
+
"Use [b]open[/] (the default) for rendering the dependency graph using an online service or [b]print[/] for printing the graph URL on the standard output without opening the browser\n"+
73
+
"Both options can be combined with a comma, i.e. [b]open,print[/] to both open the URL and print it")]
[Description($"The direction of the dependency graph. Possible values are [b]{nameof(GraphDirection.LeftToRight)}[/] and [b]{nameof(GraphDirection.TopToBottom)}[/]")]
78
+
[Description($"The direction of the dependency graph, possible values are [b]{nameof(GraphDirection.LeftToRight)}[/] (recommended for large graphs) and [b]{nameof(GraphDirection.TopToBottom)}[/] (good for small graphs)")]
55
79
[DefaultValue(GraphDirection.LeftToRight)]
56
80
publicGraphDirectionGraphDirection{get;init;}
57
81
58
82
[CommandOption("-t|--title <GRAPH_TITLE>")]
59
-
[Description("The title of the dependency graph.")]
83
+
[Description("The title of the dependency graph")]
60
84
[DefaultValue(DefaultTitle)]
61
85
publicstringTitle{get;set;}="";
62
86
63
87
[CommandOption("-s|--include-version")]
64
-
[Description("Include package versions in the dependency graph. E.g. [b]Serilog/4.3.0[/] instead of [b]Serilog[/]")]
88
+
[Description("Include package versions in the dependency graph nodes, e.g. [b]Serilog/4.3.0[/] instead of [b]Serilog[/]")]
65
89
[DefaultValue(false)]
66
90
publicboolGraphIncludeVersions{get;init;}
67
91
68
92
[CommandOption("-i|--ignore <PACKAGE>")]
69
-
[Description("Packages to ignore in the dependency graph. Supports * wildcards. May be used multiple times.")]
93
+
[Description("Packages to ignore in the dependency graph, may be used multiple times and supports * wildcards, e.g. [b]--ignore \"System.*\"[/]")]
70
94
publicstring[]GraphIgnore{get;init;}=[];
71
95
72
96
[CommandOption("--no-links")]
73
-
[Description("Remove clickable links from the the dependency graph. Can be useful to reduce the size of the graph if you get \"Maximum text size in diagram exceeded\" in Mermaid Live Editor.")]
97
+
[Description("Remove clickable links from the the dependency graph\n"+
98
+
"Can be useful to reduce the size of the graph if it becomes too large and Mermaid Live Editor is returning \"Maximum text size in diagram exceeded\" ")]
74
99
[DefaultValue(false)]
75
100
publicboolNoLinks{get;set;}
76
101
77
-
[CommandOption("--no-browser")]
78
-
[Description("Do not open the default browser, only print the graph URL on the console when the [b]--output[/] option is not specified.")]
79
-
[DefaultValue(false)]
80
-
publicboolNoBrowser{get;set;}
81
-
82
102
[CommandOption("-l|--log <LEVEL>")]
83
-
[Description($"The NuGet operations log level. Possible values are [b]{nameof(LogLevel.Debug)}[/], [b]{nameof(LogLevel.Verbose)}[/], [b]{nameof(LogLevel.Information)}[/], [b]{nameof(LogLevel.Minimal)}[/], [b]{nameof(LogLevel.Warning)}[/] and [b]{nameof(LogLevel.Error)}[/]")]
103
+
[Description($"The NuGet operations log level, possible values are [b]{nameof(LogLevel.Debug)}[/], [b]{nameof(LogLevel.Verbose)}[/], [b]{nameof(LogLevel.Information)}[/], [b]{nameof(LogLevel.Minimal)}[/], [b]{nameof(LogLevel.Warning)}[/] and [b]{nameof(LogLevel.Error)}[/]")]
84
104
#if DEBUG
85
105
[DefaultValue(LogLevel.Debug)]
86
106
#else
@@ -89,20 +109,20 @@ internal sealed class GraphCommandSettings : CommandSettings
0 commit comments