File tree Expand file tree Collapse file tree 2 files changed +21
-4
lines changed Expand file tree Collapse file tree 2 files changed +21
-4
lines changed Original file line number Diff line number Diff line change @@ -10,18 +10,34 @@ internal sealed class RenderCommand : CommandBase
1010 public RenderCommand ( )
1111 : base ( "render" , "Render a markdown file, for diagnosis purpose." )
1212 {
13- var file = new Argument < FileInfo > ( "file" , "The file path to save the code to." ) ;
13+ var file = new Argument < string > ( "file" , "The file path to save the code to." ) ;
1414 var append = new Option < bool > ( "--streaming" , "Render in the streaming manner." ) ;
1515
1616 AddArgument ( file ) ;
1717 AddOption ( append ) ;
18- this . SetHandler ( SaveAction , file , append ) ;
18+ this . SetHandler ( RenderAction , file , append ) ;
1919 }
2020
21- private void SaveAction ( FileInfo file , bool streaming )
21+ private void RenderAction ( string path , bool streaming )
2222 {
2323 var host = Shell . Host ;
2424
25+ if ( string . IsNullOrEmpty ( path ) )
26+ {
27+ host . WriteErrorLine ( $ "Please specify a file path for rendering its content.") ;
28+ return ;
29+ }
30+
31+ path = Utils . ResolveTilde ( path ) ;
32+ FileInfo file = new ( path ) ;
33+
34+ string fullName = file . FullName ;
35+ if ( Directory . Exists ( fullName ) )
36+ {
37+ host . WriteErrorLine ( $ "The specified path '{ fullName } ' points to an existing directory. Please specify a file path instead.") ;
38+ return ;
39+ }
40+
2541 try
2642 {
2743 using FileStream stream = file . OpenRead ( ) ;
Original file line number Diff line number Diff line change @@ -89,6 +89,7 @@ private List<CompletionResult> CompleteCommandName(string wildcard)
8989 private List < CompletionResult > CompleteFileSystemPath ( string wordToComplete )
9090 {
9191 bool startsWithTilde = false ;
92+ bool alreadyQuoted = wordToComplete . Contains ( ' ' ) ;
9293 string homeDirectory = null ;
9394 List < CompletionResult > result = null ;
9495
@@ -105,7 +106,7 @@ static bool StartsWithTilde(string path)
105106 string QuoteIfNeeded ( string path )
106107 {
107108 // Do not add quoting if the original string is already quoted.
108- return ! wordToComplete . Contains ( ' ' ) && path . Contains ( ' ' ) ? $ "\" { path } \" " : path ;
109+ return ! alreadyQuoted && path . Contains ( ' ' ) ? $ "\" { path } \" " : path ;
109110 }
110111
111112 // Add one result to the result list.
You can’t perform that action at this time.
0 commit comments