public static AliasExpansionStatus TryExpandAliases(INewCommandInput commandInput, AliasRegistry aliasRegistry) { List <string> inputTokens = commandInput.Tokens.ToList(); inputTokens.RemoveAt(0); // remove the command name if (aliasRegistry.TryExpandCommandAliases(inputTokens, out IReadOnlyList <string> expandedTokens)) { if (!expandedTokens.SequenceEqual(inputTokens)) { commandInput.ResetArgs(expandedTokens.ToArray()); return(AliasExpansionStatus.Expanded); } return(AliasExpansionStatus.NoChange); } return(AliasExpansionStatus.ExpansionError); }
public static AliasExpansionStatus TryExpandAliases(INewCommandInput commandInput, AliasRegistry aliasRegistry) { List <string> inputTokens = commandInput.Tokens.ToList(); inputTokens.RemoveAt(0); // remove the command name if (aliasRegistry.TryExpandCommandAliases(inputTokens, out IReadOnlyList <string> expandedTokens)) { // TryExpandCommandAliases() return value indicates error (cycle) or not error. It doesn't indicate whether or not expansions actually occurred. if (!expandedTokens.SequenceEqual(inputTokens)) { commandInput.ResetArgs(expandedTokens.ToArray()); return(AliasExpansionStatus.Expanded); } return(AliasExpansionStatus.NoChange); } return(AliasExpansionStatus.ExpansionError); }