Skip to content

Commit bcaa553

Browse files
committed
+ Added return FlowCommandResult from RunCommandAsync
1 parent 054bb84 commit bcaa553

File tree

1 file changed

+26
-6
lines changed

1 file changed

+26
-6
lines changed

src/FlowCommandLine/CommandLine.cs

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,31 +93,51 @@ public CommandLine Application ( string applicationName, string version, string
9393
/// <summary>
9494
/// Run the command from the command line.
9595
/// </summary>
96-
public Task RunCommandAsync () {
96+
public async Task<FlowCommandResult> RunCommandAsync () {
9797
if ( IsVersion () ) {
9898
ShowVersion ();
99-
return Task.CompletedTask;
99+
100+
return new FlowCommandResult {
101+
EmptyInput = string.IsNullOrEmpty ( m_commandLine ),
102+
CommandHandled = false,
103+
Handled = true
104+
};
100105
}
101106

102107
var parts = GetParts ();
103108
if ( string.IsNullOrEmpty ( m_commandLine ) || !parts.Any () || IsHelpParameter ( m_commandLine ) || parts.Any ( IsHelpParameter ) ) {
104109
ShowHelp ( parts, true );
105-
return Task.CompletedTask;
110+
111+
return new FlowCommandResult {
112+
EmptyInput = string.IsNullOrEmpty ( m_commandLine ),
113+
CommandHandled = false,
114+
Handled = parts.Any ()
115+
};
106116
}
107117

108118
ParseParameters ( parts, out var command, out var parameters );
109119

110120
try {
111121
if ( m_commands.TryGetValue ( command, out var flowCommand ) ) {
112122
flowCommand.Execute ( parameters, m_commandLineProvider );
113-
return Task.CompletedTask;
123+
124+
return new FlowCommandResult {
125+
EmptyInput = string.IsNullOrEmpty ( m_commandLine ),
126+
CommandHandled = true,
127+
Handled = false
128+
};
114129
}
115-
if ( m_asyncCommands.TryGetValue ( command, out var flowAsyncCommand ) ) return flowAsyncCommand.Execute ( parameters, m_commandLineProvider );
130+
if ( m_asyncCommands.TryGetValue ( command, out var flowAsyncCommand ) ) await flowAsyncCommand.Execute ( parameters, m_commandLineProvider );
116131
} catch {
117132
}
118133

119134
ShowHelp ( parts );
120-
return Task.CompletedTask;
135+
136+
return new FlowCommandResult {
137+
EmptyInput = string.IsNullOrEmpty ( m_commandLine ),
138+
CommandHandled = false,
139+
Handled = false
140+
};
121141
}
122142

123143
/// <summary>

0 commit comments

Comments
 (0)