public static HelpDetails Expressions() { HelpDetails details = new HelpDetails(); details.Description = "Allows logical testing against fields and attributes"; details.Usage = "[@field | @@attribute] operator [@field | @@attribute] [as cast] [with flag] [and | or expression]"; details.AddParameter("operator", "How to compare the 2 arguments. Must be one of = (equals), < (less than), > (greater than), != (not equal), <= (less or equal), >= (greater or equal), [ (starts with), ] (ends with), ? (contains), !? (doesn't contain)."); details.AddParameter("cast", "Treat the argument as a specific data type. Must be one of string, number, date."); details.AddParameter("flag", "Treat the argument in a specific way. Must be one of ignorecase, ignoredecimal, round, ceiling, floor."); details.AddParameter("expression", "Another expression. The operator (and, or) is used to determine the overall result"); details.Comments = "Expressions are used as arguments to other commands such as find."; details.AddExample("@title != hello"); details.AddExample("(@__created by) = admin with ignorecase"); details.AddExample("@price >= 70 as number with round and @title = bananas with ignorecase"); details.AddExample("@@key = a or @@key = b or @@key = c"); details.AddExample("@__created = 12/01/2007 as date"); details.AddExample("@@name [ a"); return details; }
public static HelpDetails UseEnvironmentVariable() { HelpDetails details = new HelpDetails(); details.Description = "Allows substitution of environment variables into commands"; details.Usage = "$name$"; details.AddParameter("name", "The name of the environment variable"); details.AddExample("$prevpath$"); details.AddExample("$myvar$"); details.AddExample("echo $prevpath$"); return details; }
public static HelpDetails SubCommand() { HelpDetails details = new HelpDetails(); details.Description = "Allows the evaluation of a command to be used as a parameter of another command"; details.Usage = "< command"; details.AddParameter("command", "The command to evaluate"); details.AddExample("sf title < (gf -f title ../..)"); details.AddExample("find echo < (ga -a key) < (ga -a id)"); details.AddExample("cd < (ga -a templateid)"); return details; }
public HelpDetails GetScriptHelp(string name) { var scriptsItems = FindScriptItems(name); if (scriptsItems == null) return null; if (scriptsItems.Length == 1) { var scriptItem = scriptsItems[0]; HelpDetails details = new HelpDetails(); if (scriptItem[Constants.Fields.Description] != string.Empty) details.Description = scriptItem[Constants.Fields.Description]; if (scriptItem[Constants.Fields.Usage] != string.Empty) details.Usage = scriptItem[Constants.Fields.Usage]; if (scriptItem[Constants.Fields.Comments] != string.Empty) details.Comments = scriptItem[Constants.Fields.Comments]; Item[] parameters = scriptItem.Axes.SelectItems("*[@@templatekey='script help parameter']"); if (parameters != null) { for (int i = 0; i < parameters.Length; i++) { details.AddParameter(parameters[i][Constants.Fields.Name], parameters[i][Constants.Fields.Description]); } } Item[] examples = scriptItem.Axes.SelectItems("*[@@templatekey='script help example']"); if (examples != null) { for (int i = 0; i < examples.Length; i++) { details.AddExample(examples[i][Constants.Fields.Example]); } } return details; } if (scriptsItems.Length > 1) { var scriptPaths = from script in scriptsItems select script.Paths.FullPath; throw new MultipleScriptsFoundException(scriptPaths); } return null; }
public HelpDetails GetScriptHelp(string name) { var scriptSource = GetScript(name); // Check if the script exists. If not, return null if (scriptSource == null) return null; var helpData = ExtractHelpData(scriptSource); var details = new HelpDetails(); foreach (var entry in helpData) { switch (entry.Key.ToLower()) { case "comments": details.Comments += entry.Value; break; case "description": details.Description += entry.Value; break; case "example": details.AddExample(entry.Value); break; case "parameter": var idx = entry.Value.IndexOf(HelpCommentDelimiter); if (entry.Value.Length > idx) { var key = entry.Value.Substring(0, idx); var desc = entry.Value.Substring(idx + 1); details.AddParameter(key, desc); } break; case "usage": details.Usage = entry.Value; break; } } return details; }
public static HelpDetails Prompt() { HelpDetails details = new HelpDetails(); details.Description = "The prompt is set through the environment variable 'prompt'"; //details.Usage = "[Any characters] [%path%] [%itemname%] [%ver%] [%db%] [%lang%] [%date%] [%time%] >"; details.Usage = "[Any characters] [%path%] [%itemname%] [%ver%] [%db%] [%lang%] [%langcode%] [%date%] [%time%]"; details.AddParameter("%path%", "Provides the full path of the current item"); details.AddParameter("%itemname%", "Provides the name of the current item"); details.AddParameter("%ver%", "Provides the version number of the current item"); details.AddParameter("%db%", "Provides the name of the current database"); details.AddParameter("%lang%", "Provides the title of the current language"); details.AddParameter("%langcode", "Provides the code of the current language"); details.AddParameter("%date%", "Provides the current date"); details.AddParameter("%time%", "Provides the current time"); //details.Comments = "The prompt must end with a right angle bracket '>'"; details.AddExample("%db%:%path% >"); details.AddExample("%date% %lang%|%itemname% >"); return details; }
private void AddParameterToHelp(HelpDetails details, string name, DescriptionAttribute description, bool optional) { details.AddParameter(name, (optional ? "Optional. " : string.Empty) + (description != null ? description.Description : string.Empty)); }