public EnumTabCompletionSource(CommandLineArgumentsDefinition definition, CommandLineArgument argument) : base(definition, argument) { var options = Enum.GetNames(argument.ArgumentType).Union(argument.ArgumentType.GetEnumShortcuts()); wrappedSource = new SimpleTabCompletionSource(options); }
public EnumTabCompletionSource(CommandLineArgument target) { this.target = target; var options = Enum.GetNames(target.ArgumentType).Union(target.ArgumentType.GetEnumShortcuts()); wrappedSource = new SimpleTabCompletionSource(options) { MinCharsBeforeCyclingBegins = 0 }; }
public bool TryComplete(TabCompletionContext context, out string completion) { if (actionSource == null) { actionSource = new SimpleTabCompletionSource(FindActions(context.Definition)) { MinCharsBeforeCyclingBegins = 0 }; globalArgumentSource = new SimpleTabCompletionSource(FindGlobalArguments(context.Definition)) { MinCharsBeforeCyclingBegins = 0 }; actionSpecificArgumentSources = FindActionSpecificSources(context.Definition); } // if this is the first token and the definition contains actions then try to auto complete an action name if (string.IsNullOrEmpty(context.PreviousToken) && context.Definition.Actions.Count > 0) { return(actionSource.TryComplete(context, out completion)); } // if there is no action in context and no argument in context then try to auto complete global argument names else if (context.TargetAction == null && context.TargetArgument == null) { return(globalArgumentSource.TryComplete(context, out completion)); } // if there is an action in context and not argument in context then try to complete action specific argument names and then globals else if (context.TargetAction != null && context.TargetArgument == null) { var actionSpecificSource = actionSpecificArgumentSources[context.TargetAction]; if (actionSpecificSource.TryComplete(context, out completion)) { return(true); } else { return(globalArgumentSource.TryComplete(context, out completion)); } } else { completion = null; return(false); } }
public bool TryComplete(TabCompletionContext context, out string completion) { if(actionSource == null) { actionSource = new SimpleTabCompletionSource(FindActions(context.Definition)) { MinCharsBeforeCyclingBegins = 0 }; globalArgumentSource = new SimpleTabCompletionSource(FindGlobalArguments(context.Definition)) { MinCharsBeforeCyclingBegins = 0 }; actionSpecificArgumentSources = FindActionSpecificSources(context.Definition); } // if this is the first token and the definition contains actions then try to auto complete an action name if(string.IsNullOrEmpty(context.PreviousToken) && context.Definition.Actions.Count > 0) { return actionSource.TryComplete(context, out completion); } // if there is no action in context and no argument in context then try to auto complete global argument names else if(context.TargetAction == null && context.TargetArgument == null) { return globalArgumentSource.TryComplete(context, out completion); } // if there is an action in context and not argument in context then try to complete action specific argument names and then globals else if(context.TargetAction != null && context.TargetArgument == null) { var actionSpecificSource = actionSpecificArgumentSources[context.TargetAction]; if (actionSpecificSource.TryComplete(context, out completion)) { return true; } else { return globalArgumentSource.TryComplete(context, out completion); } } else { completion = null; return false; } }
public EnumTabCompletionSource(CommandLineArgument target) { this.target = target; var options = Enum.GetNames(target.ArgumentType).Union(target.ArgumentType.GetEnumShortcuts()); wrappedSource = new SimpleTabCompletionSource(options) { MinCharsBeforeCyclingBegins = 0}; }