public void AddCommand(string category, string command, string shortName, string arguments, string description, string longDescription, SetupCommandHandler handler) { SetupCommand cmd = new SetupCommand(category, command, shortName, handler); cmd.Usage = arguments; cmd.Description = description; cmd.LongDescription = longDescription; bool foundCat = false; for (int n = 0; n < commands.Count; n++) { SetupCommand ec = (SetupCommand)commands [n]; if (ec.Category == category) { foundCat = true; } else if (foundCat) { commands.Insert(n, cmd); break; } } if (!foundCat) { commands.Add(cmd); } }
public void AddCommand(string category, string command, string shortName, string arguments, string description, string longDescription, SetupCommandHandler handler) { SetupCommand cmd = new SetupCommand(category, command, shortName, handler); cmd.Usage = arguments; cmd.Description = description; cmd.LongDescription = longDescription; int lastCatPos = -1; for (int n = 0; n < commands.Count; n++) { SetupCommand ec = (SetupCommand)commands [n]; if (ec.Category == category) { lastCatPos = n; } } if (lastCatPos == -1) { commands.Add(cmd); } else { commands.Insert(lastCatPos + 1, cmd); } }
int RunCommand(string cmd, string[] parms) { SetupCommand cc = FindCommand(cmd); if (cc != null) { cc.Handler(parms); return(0); } else { Console.WriteLine("Unknown command: " + cmd); return(1); } }
void PrintHelp(params string[] parms) { if (parms.Length == 0) { string lastCat = null; foreach (SetupCommand cmd in commands) { if (lastCat != cmd.Category) { Console.WriteLine(); Console.WriteLine(cmd.Category + ":"); lastCat = cmd.Category; } string cc = cmd.CommandDesc; if (cc.Length < 16) { cc += new string (' ', 16 - cc.Length); } Console.WriteLine(" " + cc + " " + cmd.Description); } Console.WriteLine(); Console.WriteLine("Run '" + setupAppName + "help <command>' to get help about a specific command."); Console.WriteLine(); return; } else { Console.WriteLine(); SetupCommand cmd = FindCommand(parms [0]); if (cmd != null) { Console.WriteLine("{0}: {1}", cmd.CommandDesc, cmd.Description); Console.WriteLine(); Console.WriteLine("Usage: {0}{1}", setupAppName, cmd.Usage); Console.WriteLine(); Console.WriteLine(cmd.LongDescription); } else { Console.WriteLine("Unknown command: " + parms [0]); } Console.WriteLine(); } }
void CreateCommands() { SetupCommand cmd; string cat = "Add-in commands"; cmd = new SetupCommand(cat, "install", "i", new SetupCommandHandler(Install)); cmd.Description = "Installs add-ins."; cmd.Usage = "[package-name|package-file] ..."; cmd.AppendDesc("Installs an add-in or set of addins. The command argument is a list"); cmd.AppendDesc("of files and/or package names. If a package name is provided"); cmd.AppendDesc("the package will be looked out in the registered repositories."); cmd.AppendDesc("A specific add-in version can be specified by appending it to."); cmd.AppendDesc("the package name using '/' as a separator, like in this example:"); cmd.AppendDesc("MonoDevelop.SourceEditor/0.9.1"); commands.Add(cmd); cmd = new SetupCommand(cat, "uninstall", "u", new SetupCommandHandler(Uninstall)); cmd.Description = "Uninstalls add-ins."; cmd.Usage = "<package-name>"; cmd.AppendDesc("Uninstalls an add-in. The command argument is the name"); cmd.AppendDesc("of the add-in to uninstall."); commands.Add(cmd); cmd = new SetupCommand(cat, "update", "up", new SetupCommandHandler(Update)); cmd.Description = "Updates installed add-ins."; cmd.AppendDesc("Downloads and installs available updates for installed add-ins."); commands.Add(cmd); cmd = new SetupCommand(cat, "list", "l", new SetupCommandHandler(ListInstalled)); cmd.Description = "Lists installed add-ins."; cmd.AppendDesc("Prints a list of all installed add-ins."); commands.Add(cmd); cmd = new SetupCommand(cat, "list-av", "la", new SetupCommandHandler(ListAvailable)); cmd.Description = "Lists add-ins available in registered repositories."; cmd.AppendDesc("Prints a list of add-ins available to install in the"); cmd.AppendDesc("registered repositories."); commands.Add(cmd); cmd = new SetupCommand(cat, "list-update", "lu", new SetupCommandHandler(ListUpdates)); cmd.Description = "Lists available add-in updates."; cmd.AppendDesc("Prints a list of available add-in updates in the registered repositories."); commands.Add(cmd); cat = "Repository Commands"; cmd = new SetupCommand(cat, "rep-add", "ra", new SetupCommandHandler(AddRepository)); cmd.Description = "Registers repositories."; cmd.Usage = "<url> ..."; cmd.AppendDesc("Registers an add-in repository. Several URLs can be provided."); commands.Add(cmd); cmd = new SetupCommand(cat, "rep-remove", "rr", new SetupCommandHandler(RemoveRepository)); cmd.Description = "Unregisters repositories."; cmd.Usage = "<url> ..."; cmd.AppendDesc("Unregisters an add-in repository. Several URLs can be provided."); commands.Add(cmd); cmd = new SetupCommand(cat, "rep-update", "ru", new SetupCommandHandler(UpdateAvailableAddins)); cmd.Description = "Updates the lists of available addins."; cmd.AppendDesc("Updates the lists of addins available in all registered repositories."); commands.Add(cmd); cmd = new SetupCommand(cat, "rep-list", "rl", new SetupCommandHandler(ListRepositories)); cmd.Description = "Lists registered repositories."; cmd.AppendDesc("Shows a list of all registered repositories."); commands.Add(cmd); cat = "Add-in Registry Commands"; cmd = new SetupCommand(cat, "reg-update", "rgu", new SetupCommandHandler(UpdateRegistry)); cmd.Description = "Updates the add-in registry."; cmd.AppendDesc("Looks for changes in add-in directories and updates the registry."); cmd.AppendDesc("New add-ins will be added and deleted add-ins will be removed."); commands.Add(cmd); cmd = new SetupCommand(cat, "reg-build", "rgu", new SetupCommandHandler(RepairRegistry)); cmd.Description = "Rebuilds the add-in registry."; cmd.AppendDesc("Regenerates the add-in registry"); commands.Add(cmd); cmd = new SetupCommand(cat, "info", null, new SetupCommandHandler(PrintAddinInfo)); cmd.Description = "Prints information about an add-in."; cmd.AppendDesc("Prints information about an add-in."); commands.Add(cmd); cat = "Packaging Commands"; cmd = new SetupCommand(cat, "rep-build", "rb", new SetupCommandHandler(BuildRepository)); cmd.Description = "Creates a repository index file for a directory structure."; cmd.Usage = "<path>"; cmd.AppendDesc("Scans the provided directory and generates a set of index files with entries"); cmd.AppendDesc("for all add-in packages found in the directory tree. The resulting file"); cmd.AppendDesc("structure is an add-in repository that can be published in a web site or a"); cmd.AppendDesc("shared directory."); commands.Add(cmd); cmd = new SetupCommand(cat, "pack", "p", new SetupCommandHandler(BuildPackage)); cmd.Description = "Creates a package from an add-in configuration file."; cmd.Usage = "<file-path>"; cmd.AppendDesc("Creates an add-in package (.mpack file) which includes all files "); cmd.AppendDesc("needed to deploy an add-in. The command parameter is the path to"); cmd.AppendDesc("the add-in's configuration file."); commands.Add(cmd); cmd = new SetupCommand(cat, "help", "h", new SetupCommandHandler(PrintHelp)); cmd.Description = "Shows help about a command."; cmd.Usage = "<command>"; commands.Add(cmd); cat = "Debug Commands"; cmd = new SetupCommand(cat, "dump-file", null, new SetupCommandHandler(DumpRegistryFile)); cmd.Description = "Prints the contents of a registry file."; cmd.Usage = "<file-path>"; cmd.AppendDesc("Prints the contents of a registry file for debugging."); commands.Add(cmd); }
void CreateCommands() { SetupCommand cmd; string cat = "Add-in commands"; cmd = new SetupCommand (cat, "install", "i", new SetupCommandHandler (Install)); cmd.Description = "Installs add-ins."; cmd.Usage = "[package-name|package-file] ..."; cmd.AppendDesc ("Installs an add-in or set of addins. The command argument is a list"); cmd.AppendDesc ("of files and/or package names. If a package name is provided"); cmd.AppendDesc ("the package will be looked up in the registered repositories."); cmd.AppendDesc ("A specific add-in version can be specified by appending it to."); cmd.AppendDesc ("the package name using '/' as a separator, like in this example:"); cmd.AppendDesc ("MonoDevelop.SourceEditor/0.9.1"); commands.Add (cmd); cmd = new SetupCommand (cat, "uninstall", "u", new SetupCommandHandler (Uninstall)); cmd.Description = "Uninstalls add-ins."; cmd.Usage = "<package-name>"; cmd.AppendDesc ("Uninstalls an add-in. The command argument is the name"); cmd.AppendDesc ("of the add-in to uninstall."); commands.Add (cmd); cmd = new SetupCommand (cat, "check-install", "ci", new SetupCommandHandler (CheckInstall)); cmd.Description = "Checks installed add-ins."; cmd.Usage = "[package-name|package-file] ..."; cmd.AppendDesc ("Checks if a package is installed. If it is not, it looks for"); cmd.AppendDesc ("the package in the registered repositories, and if found"); cmd.AppendDesc ("the package is downloaded and installed, including all"); cmd.AppendDesc ("needed dependencies."); commands.Add (cmd); cmd = new SetupCommand (cat, "update", "up", new SetupCommandHandler (Update)); cmd.Description = "Updates installed add-ins."; cmd.AppendDesc ("Downloads and installs available updates for installed add-ins."); commands.Add (cmd); cmd = new SetupCommand (cat, "list", "l", new SetupCommandHandler (ListInstalled)); cmd.Description = "Lists installed add-ins."; cmd.AppendDesc ("Prints a list of all installed add-ins."); commands.Add (cmd); cmd = new SetupCommand (cat, "list-av", "la", new SetupCommandHandler (ListAvailable)); cmd.Description = "Lists add-ins available in registered repositories."; cmd.AppendDesc ("Prints a list of add-ins available to install in the"); cmd.AppendDesc ("registered repositories."); commands.Add (cmd); cmd = new SetupCommand (cat, "list-update", "lu", new SetupCommandHandler (ListUpdates)); cmd.Description = "Lists available add-in updates."; cmd.AppendDesc ("Prints a list of available add-in updates in the registered repositories."); commands.Add (cmd); cat = "Repository Commands"; cmd = new SetupCommand (cat, "rep-add", "ra", new SetupCommandHandler (AddRepository)); cmd.Description = "Registers repositories."; cmd.Usage = "<url> ..."; cmd.AppendDesc ("Registers an add-in repository. Several URLs can be provided."); commands.Add (cmd); cmd = new SetupCommand (cat, "rep-remove", "rr", new SetupCommandHandler (RemoveRepository)); cmd.Description = "Unregisters repositories."; cmd.Usage = "<url or number> ..."; cmd.AppendDesc ("Unregisters an add-in repository. Several URLs can be provided."); cmd.AppendDesc ("Instead of an url, a repository number can be used (repository numbers are"); cmd.AppendDesc ("shown by the rep-list command."); commands.Add (cmd); cmd = new SetupCommand (cat, "rep-enable", "re", new SetupCommandHandler (EnableRepository)); cmd.Description = "Enables repositories."; cmd.Usage = "<url or number> ..."; cmd.AppendDesc ("Enables an add-in repository which has been disabled. Several URLs can be"); cmd.AppendDesc ("provided. Instead of an url, a repository number can be used (repository"); cmd.AppendDesc ("numbers are shown by the rep-list command."); commands.Add (cmd); cmd = new SetupCommand (cat, "rep-disable", "rd", new SetupCommandHandler (DisableRepository)); cmd.Description = "Disables repositories."; cmd.Usage = "<url> ..."; cmd.AppendDesc ("Disables an add-in repository. Several URLs can be provided"); cmd.AppendDesc ("When a repository is disabled, it will be ignored when using the update and"); cmd.AppendDesc ("install commands."); cmd.AppendDesc ("Instead of an url, a repository number can be used (repository numbers are"); cmd.AppendDesc ("shown by the rep-list command."); commands.Add (cmd); cmd = new SetupCommand (cat, "rep-update", "ru", new SetupCommandHandler (UpdateAvailableAddins)); cmd.Description = "Updates the lists of available addins."; cmd.AppendDesc ("Updates the lists of addins available in all registered repositories."); commands.Add (cmd); cmd = new SetupCommand (cat, "rep-list", "rl", new SetupCommandHandler (ListRepositories)); cmd.Description = "Lists registered repositories."; cmd.AppendDesc ("Shows a list of all registered repositories."); commands.Add (cmd); cat = "Add-in Registry Commands"; cmd = new SetupCommand (cat, "reg-update", "rgu", new SetupCommandHandler (UpdateRegistry)); cmd.Description = "Updates the add-in registry."; cmd.AppendDesc ("Looks for changes in add-in directories and updates the registry."); cmd.AppendDesc ("New add-ins will be added and deleted add-ins will be removed."); commands.Add (cmd); cmd = new SetupCommand (cat, "reg-build", "rgb", new SetupCommandHandler (RepairRegistry)); cmd.Description = "Rebuilds the add-in registry."; cmd.AppendDesc ("Regenerates the add-in registry"); commands.Add (cmd); cmd = new SetupCommand (cat, "info", null, new SetupCommandHandler (PrintAddinInfo)); cmd.Usage = "[addin-id|addin-file] [--xml] [--all] [--full] [--namespace <namespace>]"; cmd.Description = "Prints information about add-ins."; cmd.AppendDesc ("Prints information about add-ins. Options:\n"); cmd.AppendDesc (" --xml: Dump the information using an XML format.\n"); cmd.AppendDesc (" --all: Dump information from all add-ins.\n"); cmd.AppendDesc (" --full: Include add-ins which don't define extension points.\n"); cmd.AppendDesc (" --namespace ns: Include only add-ins from the specified 'ns' namespace."); commands.Add (cmd); cat = "Packaging Commands"; cmd = new SetupCommand (cat, "rep-build", "rb", new SetupCommandHandler (BuildRepository)); cmd.Description = "Creates a repository index file for a directory structure."; cmd.Usage = "<path>"; cmd.AppendDesc ("Scans the provided directory and generates a set of index files with entries"); cmd.AppendDesc ("for all add-in packages found in the directory tree. The resulting file"); cmd.AppendDesc ("structure is an add-in repository that can be published in a web site or a"); cmd.AppendDesc ("shared directory."); commands.Add (cmd); cmd = new SetupCommand (cat, "pack", "p", new SetupCommandHandler (BuildPackage)); cmd.Description = "Creates a package from an add-in configuration file."; cmd.Usage = "<file-path> [-d:output-directory]"; cmd.AppendDesc ("Creates an add-in package (.mpack file) which includes all files "); cmd.AppendDesc ("needed to deploy an add-in. The command parameter is the path to"); cmd.AppendDesc ("the add-in's configuration file."); commands.Add (cmd); cmd = new SetupCommand (cat, "help", "h", new SetupCommandHandler (PrintHelp)); cmd.Description = "Shows help about a command."; cmd.Usage = "<command>"; commands.Add (cmd); cat = "Build Commands"; cmd = new SetupCommand (cat, "libraries", "libs", new SetupCommandHandler (PrintLibraries)); cmd.Description = "Lists add-in assemblies."; cmd.Usage = "[-r] <addin-id> ..."; cmd.AppendDesc ("Prints a list of assemblies exported by the add-in or add-ins provided"); cmd.AppendDesc ("as arguments. This list of assemblies can be used as references for"); cmd.AppendDesc ("building add-ins that depend on them. If the -r option is specified,"); cmd.AppendDesc ("each assembly is prefixed with '-r:'."); commands.Add (cmd); cmd = new SetupCommand (cat, "applications", "apps", new SetupCommandHandler (PrintApplications)); cmd.Description = "Lists extensible applications."; cmd.AppendDesc ("Prints a list of registered extensible applications."); commands.Add (cmd); cat = "Debug Commands"; cmd = new SetupCommand (cat, "dump-file", null, new SetupCommandHandler (DumpRegistryFile)); cmd.Description = "Prints the contents of a registry file."; cmd.Usage = "<file-path>"; cmd.AppendDesc ("Prints the contents of a registry file for debugging."); commands.Add (cmd); }
/// <summary> /// Adds a custom command to the add-in manager /// </summary> /// <param name="category"> /// Category under which the command has to be shown in the help text /// </param> /// <param name="command"> /// Name of the command /// </param> /// <param name="shortName"> /// Short name of the command (it's an alias of the normal name) /// </param> /// <param name="arguments"> /// Formal description of the arguments that the command accepts. For example: "[addin-id|addin-file] [--xml] [--all] [--full] [--namespace <namespace>]" /// </param> /// <param name="description"> /// Short description of the command /// </param> /// <param name="longDescription"> /// Long description of the command /// </param> /// <param name="handler"> /// Delegate to be invoked to run the command /// </param> public void AddCommand(string category, string command, string shortName, string arguments, string description, string longDescription, SetupCommandHandler handler) { SetupCommand cmd = new SetupCommand (category, command, shortName, handler); cmd.Usage = arguments; cmd.Description = description; cmd.LongDescription = longDescription; int lastCatPos = -1; for (int n=0; n<commands.Count; n++) { SetupCommand ec = (SetupCommand) commands [n]; if (ec.Category == category) lastCatPos = n; } if (lastCatPos == -1) commands.Add (cmd); else commands.Insert (lastCatPos+1, cmd); }
void CreateCommands () { SetupCommand cmd; string cat = "Add-in commands"; cmd = new SetupCommand (cat, "install", "i", new SetupCommandHandler (Install)); cmd.Description = "Installs add-ins."; cmd.Usage = "[package-name|package-file] ..."; cmd.AppendDesc ("Installs an add-in or set of addins. The command argument is a list"); cmd.AppendDesc ("of files and/or package names. If a package name is provided"); cmd.AppendDesc ("the package will be looked out in the registered repositories."); cmd.AppendDesc ("A specific add-in version can be specified by appending it to."); cmd.AppendDesc ("the package name using '/' as a separator, like in this example:"); cmd.AppendDesc ("MonoDevelop.SourceEditor/0.9.1"); commands.Add (cmd); cmd = new SetupCommand (cat, "uninstall", "u", new SetupCommandHandler (Uninstall)); cmd.Description = "Uninstalls add-ins."; cmd.Usage = "<package-name>"; cmd.AppendDesc ("Uninstalls an add-in. The command argument is the name"); cmd.AppendDesc ("of the add-in to uninstall."); commands.Add (cmd); cmd = new SetupCommand (cat, "check-install", "ci", new SetupCommandHandler (CheckInstall)); cmd.Description = "Checks installed add-ins."; cmd.Usage = "[package-name|package-file] ..."; cmd.AppendDesc ("Checks if a package is installed. If it is not, it looks for"); cmd.AppendDesc ("the package in the registered repositories, and if found"); cmd.AppendDesc ("the package is downloaded and installed, including all"); cmd.AppendDesc ("needed dependencies."); commands.Add (cmd); cmd = new SetupCommand (cat, "update", "up", new SetupCommandHandler (Update)); cmd.Description = "Updates installed add-ins."; cmd.AppendDesc ("Downloads and installs available updates for installed add-ins."); commands.Add (cmd); cmd = new SetupCommand (cat, "list", "l", new SetupCommandHandler (ListInstalled)); cmd.Description = "Lists installed add-ins."; cmd.AppendDesc ("Prints a list of all installed add-ins."); commands.Add (cmd); cmd = new SetupCommand (cat, "list-av", "la", new SetupCommandHandler (ListAvailable)); cmd.Description = "Lists add-ins available in registered repositories."; cmd.AppendDesc ("Prints a list of add-ins available to install in the"); cmd.AppendDesc ("registered repositories."); commands.Add (cmd); cmd = new SetupCommand (cat, "list-update", "lu", new SetupCommandHandler (ListUpdates)); cmd.Description = "Lists available add-in updates."; cmd.AppendDesc ("Prints a list of available add-in updates in the registered repositories."); commands.Add (cmd); cat = "Repository Commands"; cmd = new SetupCommand (cat, "rep-add", "ra", new SetupCommandHandler (AddRepository)); cmd.Description = "Registers repositories."; cmd.Usage = "<url> ..."; cmd.AppendDesc ("Registers an add-in repository. Several URLs can be provided."); commands.Add (cmd); cmd = new SetupCommand (cat, "rep-remove", "rr", new SetupCommandHandler (RemoveRepository)); cmd.Description = "Unregisters repositories."; cmd.Usage = "<url> ..."; cmd.AppendDesc ("Unregisters an add-in repository. Several URLs can be provided."); commands.Add (cmd); cmd = new SetupCommand (cat, "rep-update", "ru", new SetupCommandHandler (UpdateAvailableAddins)); cmd.Description = "Updates the lists of available addins."; cmd.AppendDesc ("Updates the lists of addins available in all registered repositories."); commands.Add (cmd); cmd = new SetupCommand (cat, "rep-list", "rl", new SetupCommandHandler (ListRepositories)); cmd.Description = "Lists registered repositories."; cmd.AppendDesc ("Shows a list of all registered repositories."); commands.Add (cmd); cat = "Add-in Registry Commands"; cmd = new SetupCommand (cat, "reg-update", "rgu", new SetupCommandHandler (UpdateRegistry)); cmd.Description = "Updates the add-in registry."; cmd.AppendDesc ("Looks for changes in add-in directories and updates the registry."); cmd.AppendDesc ("New add-ins will be added and deleted add-ins will be removed."); commands.Add (cmd); cmd = new SetupCommand (cat, "reg-build", "rgu", new SetupCommandHandler (RepairRegistry)); cmd.Description = "Rebuilds the add-in registry."; cmd.AppendDesc ("Regenerates the add-in registry"); commands.Add (cmd); cmd = new SetupCommand (cat, "info", null, new SetupCommandHandler (PrintAddinInfo)); cmd.Description = "Prints information about an add-in."; cmd.AppendDesc ("Prints information about an add-in."); commands.Add (cmd); cat = "Packaging Commands"; cmd = new SetupCommand (cat, "rep-build", "rb", new SetupCommandHandler (BuildRepository)); cmd.Description = "Creates a repository index file for a directory structure."; cmd.Usage = "<path>"; cmd.AppendDesc ("Scans the provided directory and generates a set of index files with entries"); cmd.AppendDesc ("for all add-in packages found in the directory tree. The resulting file"); cmd.AppendDesc ("structure is an add-in repository that can be published in a web site or a"); cmd.AppendDesc ("shared directory."); commands.Add (cmd); cmd = new SetupCommand (cat, "pack", "p", new SetupCommandHandler (BuildPackage)); cmd.Description = "Creates a package from an add-in configuration file."; cmd.Usage = "<file-path>"; cmd.AppendDesc ("Creates an add-in package (.mpack file) which includes all files "); cmd.AppendDesc ("needed to deploy an add-in. The command parameter is the path to"); cmd.AppendDesc ("the add-in's configuration file."); commands.Add (cmd); cmd = new SetupCommand (cat, "help", "h", new SetupCommandHandler (PrintHelp)); cmd.Description = "Shows help about a command."; cmd.Usage = "<command>"; commands.Add (cmd); cat = "Debug Commands"; cmd = new SetupCommand (cat, "dump-file", null, new SetupCommandHandler (DumpRegistryFile)); cmd.Description = "Prints the contents of a registry file."; cmd.Usage = "<file-path>"; cmd.AppendDesc ("Prints the contents of a registry file for debugging."); commands.Add (cmd); }
public void AddCommand (string category, string command, string shortName, string arguments, string description, string longDescription, SetupCommandHandler handler) { SetupCommand cmd = new SetupCommand (category, command, shortName, handler); cmd.Usage = arguments; cmd.Description = description; cmd.LongDescription = longDescription; bool foundCat = false; for (int n=0; n<commands.Count; n++) { SetupCommand ec = (SetupCommand) commands [n]; if (ec.Category == category) foundCat = true; else if (foundCat) { commands.Insert (n, cmd); break; } } if (!foundCat) commands.Add (cmd); }