public static int Complete(string[] args, [CanBeNull] string rootDirectory, [CanBeNull] string buildScript) { var words = args.Single(); if (!words.StartsWithOrdinalIgnoreCase("nuke")) { return(0); } if (rootDirectory == null) { // TODO: parse --root parameter return(0); } var completionFile = Constants.GetCompletionFile((PathConstruction.AbsolutePath)rootDirectory); if (!File.Exists(completionFile)) { Build(buildScript.NotNull(), $"--{Constants.CompletionParameterName}"); return(1); } words = words.Substring("nuke ".Length); var position = ParameterService.Instance.GetParameter <int?>("position"); var completionItems = SerializationTasks.YamlDeserializeFromFile <Dictionary <string, string[]> >(completionFile); foreach (var item in GetRelevantCompletionItems(words, position, completionItems)) { Console.WriteLine(item); } return(0); }
public static int Complete(string[] args, [CanBeNull] string rootDirectory, [CanBeNull] string buildScript) { if (rootDirectory == null) { return(0); } var words = args.Single(); if (!words.StartsWithOrdinalIgnoreCase(CommandName)) { return(0); } words = words.Substring(CommandName.Length).TrimStart(); var completionFile = GetCompletionFile((AbsolutePath)rootDirectory); if (!File.Exists(completionFile)) { Build(buildScript.NotNull(), $"--{CompletionParameterName}"); return(1); } var position = EnvironmentInfo.GetParameter <int?>("position"); var completionItems = SerializationTasks.YamlDeserializeFromFile <Dictionary <string, string[]> >(completionFile); foreach (var item in CompletionUtility.GetRelevantCompletionItems(words, completionItems)) { Console.WriteLine(item); } return(0); }