public override void Invoke(CommandInvocationContext context) { if (PackageLogic.Instance.PackagesCollection.Packages.Count > 0) { List <Packages.Package> packagesToList = new List <Packages.Package>(); foreach (var pkg in PackageLogic.Instance.PackagesCollection.Packages) { bool isLoaded = PackageLogic.Instance.LoadedPackages.Contains(pkg); bool add = true; if (LoadedOnly.IsPresent && !isLoaded) { add = false; } if (add) { packagesToList.Add(pkg); } } if (!string.IsNullOrWhiteSpace(Filter)) { packagesToList = packagesToList.Where(e => e.Name.IndexOf(Filter, StringComparison.OrdinalIgnoreCase) > -1).ToList(); } base.Out.Object.Write(TableRecords.CreatePackageRecordList(packagesToList.ToArray())); } else { base.Out.Object.Write(TableRecords.CreatePackageRecordList()); } }
public override void Invoke(CommandInvocationContext context) { VariableContextLogic.Instance.CurrentContext = VariableContextLogic.Instance.VariableContextCollection.Contexts .FirstOrDefault(c => c.Name.Equals(Context, StringComparison.OrdinalIgnoreCase)); base.Out.Object.Table(TableRecords.CreateVariableContextRecordList(VariableContextLogic.Instance.CurrentContext)); }
protected internal override void createHistoryCleanupJob(CommandContext commandContext) { monitor.sync(); base.createHistoryCleanupJob(commandContext); spy = Context.CommandInvocationContext; monitor.sync(); }
public override void Invoke(CommandInvocationContext context) { if (base.Confirm(string.Format("The module '{0}' will be uninstalled", ModuleName))) { if (base.Host.Modules.Uninstall(ModuleName, base.Out)) { base.Out.Standard.WriteLine(string.Format("Module '{0}' has been installed", ModuleName)); } } }
public override void Invoke(CommandInvocationContext context) { var pkg = PackageLogic.Instance.PackagesCollection.Packages .FirstOrDefault(e => e.Name.Equals(Package, StringComparison.OrdinalIgnoreCase)); base.Out.Standard.WriteLine(); base.Out.Standard.WriteLine(string.Format(" Package: {0}", pkg.Name)); base.Out.Standard.WriteLine(string.Format(" Is Loaded: {0}", PackageLogic.Instance.LoadedPackages.Contains(pkg))); base.Out.Object.Table(TableRecords.CreatePackageModuleTableRecordList(pkg.Modules.ToArray())); }
public override void Invoke(CommandInvocationContext context) { var asm = Util.LoadAssembly(Assembly); if (asm == null) { base.Out.Error.WriteLine(string.Format("Could not load assembly from assembly string '{0}'", Assembly)); return; } Package pkg = PackageLogic.Instance.PackagesCollection.Packages.FirstOrDefault(e => e.Name.Equals(Package, StringComparison.OrdinalIgnoreCase)); List <string> modulesToInstall = null; if (!string.IsNullOrWhiteSpace(Modules)) { modulesToInstall = new List <string>(Modules.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)); } int count = 0; foreach (var type in asm.GetTypes()) { if (type.GetInterface(typeof(IModule).FullName) != null) { var module = (IModule)Activator.CreateInstance(type); bool add = true; if (modulesToInstall != null && !modulesToInstall.Contains(module.Name, StringComparer.OrdinalIgnoreCase)) { add = false; } if (add) { base.Out.Verbose.WriteLine(string.Format("Adding module '{0}' from type '{1}'", module.Name, type)); if (AddModule(pkg, module)) { count++; } } } } PackageLogic.Instance.Save(); if (count > 0) { base.Out.Object.Table(TableRecords.CreatePackageRecordList(pkg)); } else { base.Out.Standard.WriteLine("No modules could be found to load"); } }
public override void Invoke(CommandInvocationContext context) { var asm = LoadAssembly(); List <string> modulesToInstall = null; if (!string.IsNullOrWhiteSpace(Modules)) { modulesToInstall = new List <string>(Modules.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)); } bool success = true; int count = 0; foreach (var type in asm.GetTypes()) { if (type.GetInterface(typeof(IModule).FullName) != null) { var module = (IModule)Activator.CreateInstance(type); bool install = true; if (modulesToInstall != null && !modulesToInstall.Contains(module.Name, StringComparer.OrdinalIgnoreCase)) { install = false; } if (install) { base.Out.Verbose.WriteLine(string.Format("Loading module '{0}' from type '{1}'", module.Name, type)); if (!base.Host.Modules.Install(type, base.Out) && success) { success = false; } count++; } } } if (success) { if (count > 0) { base.Out.Standard.WriteLine("Modules loaded successfully"); } else { base.Out.Standard.WriteLine("No modules could be found to load"); } } else { base.Out.Warning.WriteLine("The module installation finished with errors"); } }
public override void Invoke(CommandInvocationContext context) { var commands = base.Host.Commands.ToList(); if (!string.IsNullOrWhiteSpace(Filter)) { commands = commands.Where(c => c.CommandName.ToUpper().Contains(Filter.ToUpper())).ToList(); } List <dynamic> commandData = new List <dynamic>(); foreach (var command in commands) { var module = base.Host.Modules.Where(m => m.CommandTypes.Contains(command.InputCommandType)).FirstOrDefault(); bool add = true; if (!string.IsNullOrEmpty(Module) && !module.Name.Equals(Module)) { add = false; } if (add) { if (Full.IsPresent) { commandData.Add(new { Name = command.CommandName, Aliases = string.Join(", ", command.Aliases), Module = module == null ? string.Empty : module.Name, Synopsis = command.Synopsis ?? string.Empty, @Type = command.InputCommandType.FullName, @Assembly = string.Format("{0}{1}{2}", command.InputCommandType.Assembly, Environment.NewLine, command.InputCommandType.Assembly.CodeBase.Replace("file:///", string.Empty)) }); } else { commandData.Add(new { Name = command.CommandName, Aliases = string.Join(", ", command.Aliases), Module = module == null ? string.Empty : module.Name, Synopsis = command.Synopsis ?? string.Empty }); } } } base.Out.Object.Table(commandData); }
public override void Invoke(CommandInvocationContext context) { var ctx = new VariableContext() { Name = Name, Description = Description }; VariableContextLogic.Instance.VariableContextCollection.Contexts.Add(ctx); VariableContextLogic.Instance.Save(); base.Out.Object.Table(TableRecords.CreateVariableContextRecordList(ctx)); }
public override void Invoke(CommandInvocationContext context) { if (string.IsNullOrEmpty(Context) && VariableContextLogic.Instance.CurrentContext == null) { base.Out.Error.WriteLine("There is no context set or specified - please specify or set a context first"); } else { var ctx = VariableContextLogic.Instance.CurrentContext; if (!string.IsNullOrWhiteSpace(Context)) { ctx = VariableContextLogic.Instance.VariableContextCollection.Contexts.FirstOrDefault(c => c.Name.Equals(Context, StringComparison.OrdinalIgnoreCase)); } base.Out.Object.Table(TableRecords.CreateVariableRecordList(ctx.Variables.ToArray())); } }
public override void Invoke(CommandInvocationContext context) { if (base.Host.Modules.Count > 0) { List <IModule> moduleList = new List <IModule>(); foreach (var module in base.Host.Modules) { moduleList.Add(module); } base.Out.Object.Table(Component.Modules.TableRecords.CreateModuleTableRecordList(moduleList.ToArray())); } else { base.Out.Object.Table(Component.Modules.TableRecords.CreateModuleTableRecordList()); } }
public override void Invoke(CommandInvocationContext context) { var contextsToApply = new List <VariableContext>(); if (!AllContexts.IsPresent) // apply to specified or default context { VariableContext ctx = null; if (string.IsNullOrEmpty(Context)) // try to use the current context { if (VariableContextLogic.Instance.CurrentContext == null) { base.Out.Error.WriteLine("There is no context currently loaded and no context specified. Please load a context or specify a context using the 'Context' parameter first."); return; } ctx = VariableContextLogic.Instance.CurrentContext; base.Out.Verbose.WriteLine(string.Format("No context was specified - using the current context '{0}'", ctx.Name)); } else // try to or use the specified context { ctx = VariableContextLogic.Instance.VariableContextCollection.Contexts.FirstOrDefault(c => c.Name.Equals(Context, StringComparison.OrdinalIgnoreCase)); } contextsToApply.Add(ctx); } else // load all to apply to { base.Out.Verbose.WriteLine("Applying variable to all contexts"); contextsToApply.AddRange(VariableContextLogic.Instance.VariableContextCollection.Contexts); } // apply to contexts var records = new List <VariableContextVariable>(); foreach (var ctxToApply in contextsToApply) { var rec = ctxToApply.Variables.FirstOrDefault(v => v.Name.Equals(Name)); if (rec != null) { records.Add(rec); } } base.Out.Object.Table(TableRecords.CreateVariableRecordList(records.ToArray())); }
public override void Invoke(CommandInvocationContext context) { if (VariableContextLogic.Instance.VariableContextCollection.Contexts.Count > 0) { var contextsToList = new List <VariableContext>(VariableContextLogic.Instance.VariableContextCollection.Contexts); if (!string.IsNullOrWhiteSpace(Filter)) { contextsToList = contextsToList.Where(e => e.Name.IndexOf(Filter, StringComparison.OrdinalIgnoreCase) > -1).ToList(); } base.Out.Object.Write(TableRecords.CreateVariableContextRecordList(contextsToList.ToArray())); } else { base.Out.Object.Write(TableRecords.CreateVariableContextRecordList()); } }
public override void Invoke(CommandInvocationContext context) { if (base.Confirm("The module will be removed.")) { var pkg = PackageLogic.Instance.PackagesCollection.Packages .FirstOrDefault(e => e.Name.Equals(Package, StringComparison.OrdinalIgnoreCase)); pkg.Modules.Remove(pkg.Modules.FirstOrDefault(m => m.Name.Equals(Module, StringComparison.OrdinalIgnoreCase))); PackageLogic.Instance.Save(); base.Out.Object.Table(TableRecords.CreatePackageRecordList(pkg)); if (PackageLogic.Instance.LoadedPackages.Contains(pkg)) { base.Out.Warning.WriteLine("This package is currently loaded and must be reloaded before the changes will take effect"); } } }
public override void Invoke(CommandInvocationContext context) { if (PackageLogic.Instance.PackagesCollection.Packages .Exists(e => e.Name.Equals(Name, StringComparison.OrdinalIgnoreCase))) { base.Out.Warning.WriteLine(string.Format("The package name '{0}' is already being used by another package", Name)); } else { var newPkg = new Packages.Package() { Name = Name }; PackageLogic.Instance.PackagesCollection.Packages.Add(newPkg); PackageLogic.Instance.Save(); base.Out.Object.Write(TableRecords.CreatePackageRecordList(newPkg)); } }
public override void Invoke(CommandInvocationContext context) { var ctx = VariableContextLogic.Instance.VariableContextCollection.Contexts.FirstOrDefault(e => e.Name.Equals(Name, StringComparison.OrdinalIgnoreCase)); if (VariableContextLogic.Instance.CurrentContext == ctx && !Force.IsPresent) { base.Out.Warning.WriteLine("The context is loaded. Unload the context, or use the 'Force' switch"); } else { if (base.Confirm("The context along with all associated variables will be deleted. This cannot be undone.", Component.ConfirmationResult.No)) { VariableContextLogic.Instance.VariableContextCollection.Contexts.Remove(ctx); VariableContextLogic.Instance.Save(); base.Out.Standard.WriteLine("Variable context deleted."); } else { base.Out.Standard.WriteLine("The variable context has NOT been deleted."); } } }
public override void Invoke(CommandInvocationContext context) { var def = base.Host.Commands.FirstOrDefault(c => c.CommandName.Equals(CommandName, StringComparison.OrdinalIgnoreCase) || c.Aliases.Contains(CommandName, StringComparer.OrdinalIgnoreCase)); WriteHeaderHelp(def); WriteSyntax(def); WriteParameters(def); WriteSwitches(def); var cmd = Host.CommandActivatorContainer.Get(def.InputCommandType); if (Details.IsPresent) { WriteDetails(cmd); } if (Examples.IsPresent) { WriteExamples(cmd); } base.Out.Standard.WriteLine(); }
public override void Invoke(CommandInvocationContext context) { if (PackageLogic.Instance.PackagesCollection.Packages.Exists(e => e.Name.Equals(Name, StringComparison.OrdinalIgnoreCase))) { if (PackageLogic.Instance.LoadedPackages.Exists(e => e.Name.Equals(Name, StringComparison.OrdinalIgnoreCase)) && !Force.IsPresent) { base.Out.Warning.WriteLine("The package is loaded. Unload the package, or use the 'Force' switch to unload the package before removing."); } else { if (base.Confirm("The package along with all associated modules will be deleted. This cannot be undone.", Component.ConfirmationResult.No)) { var pkg = PackageLogic.Instance.PackagesCollection.Packages.FirstOrDefault(e => e.Name.Equals(Name, StringComparison.OrdinalIgnoreCase)); if (PackageLogic.Instance.LoadedPackages.Exists(e => e.Name.Equals(Name, StringComparison.OrdinalIgnoreCase))) { PackageLogic.Instance.Unload(pkg, base.Host.Modules, base.Out); base.Out.Standard.WriteLine("Package unloaded."); } PackageLogic.Instance.Remove(pkg, base.Host.Modules, base.Out); PackageLogic.Instance.Save(); base.Out.Standard.WriteLine("Package deleted."); } else { base.Out.Standard.WriteLine("The package has NOT been deleted."); } } } else { base.Out.Standard.WriteLine("Package could not be found."); } }
public override void Invoke(CommandInvocationContext context) { VariableContextLogic.Instance.DiscardChanges(); Process.Start(new ProcessStartInfo(VariableContextLogic.FILE_PATH_VARIABLES)); base.Out.Warning.WriteLine("Any changes made to the variables context file will require a restart of the application to take effect. Also, any updates made to the file from within the console may overwrite your changes."); }
public override void Invoke(CommandInvocationContext context) { base.Host.Clear(); }
public override void Invoke(CommandInvocationContext context) { Process.Start(new ProcessStartInfo("explorer.exe", new UserAssemblyRepository().UserAssemblyDirectoryPath)); }
public override void Invoke(CommandInvocationContext context) { Out.Standard.WriteLine(_dep.Id); }
public override void Invoke(CommandInvocationContext context) { PackageLogic.Instance.Load(PackageLogic.Instance.PackagesCollection.Packages .FirstOrDefault(e => e.Name.Equals(Package, StringComparison.OrdinalIgnoreCase)), base.Host.Modules, base.Out); }
public override void Invoke(CommandInvocationContext context) { var contextsToApply = new List <VariableContext>(); if (!AllContexts.IsPresent) // apply to specified or default context { VariableContext ctx = null; if (string.IsNullOrEmpty(Context)) // try to use the current context { if (VariableContextLogic.Instance.CurrentContext == null) { base.Out.Error.WriteLine("There is no context currently loaded and no context specified. Please load a context or specify a context using the 'Context' parameter first."); return; } ctx = VariableContextLogic.Instance.CurrentContext; base.Out.Verbose.WriteLine(string.Format("No context was specified - using the current context '{0}'", ctx.Name)); } else // try to create and / or use the specified context { ctx = VariableContextLogic.Instance.VariableContextCollection.Contexts.FirstOrDefault(c => c.Name.Equals(Context, StringComparison.OrdinalIgnoreCase)); if (ctx == null && base.Confirm(string.Format("The context '{0}' does not exist and will be created", Context), Component.ConfirmationResult.Yes)) { ctx = new VariableContext() { Name = Context }; VariableContextLogic.Instance.VariableContextCollection.Contexts.Add(ctx); VariableContextLogic.Instance.Save(); } if (ctx == null) { base.Out.Error.WriteLine("The variable could not be set because the context was not created"); return; } } contextsToApply.Add(ctx); } else // load all to apply to { base.Out.Verbose.WriteLine("Applying variable to all contexts"); contextsToApply.AddRange(VariableContextLogic.Instance.VariableContextCollection.Contexts); } // apply to contexts foreach (var ctxToApply in contextsToApply) { if (ctxToApply.Variables.Any(v => v.Name.Equals(Name))) { if (AllContexts.IsPresent) { base.Out.Verbose.WriteLine(string.Format("Updating variable '{0}' for context '{1}' with value '{2}'" , Name, ctxToApply.Name, Value)); } else { base.Out.Verbose.WriteLine(string.Format("Updating variable '{0}' with value '{1}'" , Name, Value)); } ctxToApply.Variables.FirstOrDefault(v => v.Name.Equals(Name)).Value = Value; } else { if (AllContexts.IsPresent) { base.Out.Verbose.WriteLine(string.Format("Creating variable '{0}' for context '{1}' with value '{2}'" , Name, ctxToApply.Name, Value)); } else { base.Out.Verbose.WriteLine(string.Format("Creating variable '{0}' with value '{1}" , Name, Value)); } ctxToApply.Variables.Add(new VariableContextVariable() { Name = Name, Value = Value }); } } VariableContextLogic.Instance.Save(); base.Out.Object.Table(TableRecords.CreateVariableRecordList(new VariableContextVariable() { Name = Name, Value = Value })); }
public override void Invoke(CommandInvocationContext context) { PackageLogic.Instance.Unload(PackageLogic.Instance.LoadedPackages .FirstOrDefault(e => e.Name.Equals(Name, StringComparison.OrdinalIgnoreCase)), base.Host.Modules, base.Out); base.Out.Standard.WriteLine("Package unloaded."); }
public override void Invoke(CommandInvocationContext context) { base.Out.Object.Table(TableRecords.CreateModuleTableRecordList(false, AssemblyUtil.GetAssemblyModules(Assembly).ToArray())); }
public override void Invoke(CommandInvocationContext context) { if (base.Confirm(string.Format("The variable '{0}' will be deleted - this cannot be undone", Name), Component.ConfirmationResult.Yes)) { var contextsToApply = new List <VariableContext>(); if (!AllContexts.IsPresent) // apply to specified or default context { VariableContext ctx = null; if (string.IsNullOrEmpty(Context)) // try to use the current context { if (VariableContextLogic.Instance.CurrentContext == null) { base.Out.Error.WriteLine("There is no context currently loaded and no context specified. Please load a context or specify a context using the 'Context' parameter first."); return; } ctx = VariableContextLogic.Instance.CurrentContext; base.Out.Verbose.WriteLine(string.Format("No context was specified - using the current context '{0}'", ctx.Name)); } else // try to or use the specified context { ctx = VariableContextLogic.Instance.VariableContextCollection.Contexts.FirstOrDefault(c => c.Name.Equals(Context, StringComparison.OrdinalIgnoreCase)); } contextsToApply.Add(ctx); } else // load all to apply to { base.Out.Verbose.WriteLine("Applying variable to all contexts"); contextsToApply.AddRange(VariableContextLogic.Instance.VariableContextCollection.Contexts); } // apply to contexts foreach (var ctxToApply in contextsToApply) { if (ctxToApply.Variables.Any(v => v.Name.Equals(Name))) { if (AllContexts.IsPresent) { base.Out.Verbose.WriteLine(string.Format("Deleting variable '{0}' for context '{1}'" , Name, ctxToApply.Name)); } else { base.Out.Verbose.WriteLine(string.Format("Deleting variable '{0}'" , Name)); } ctxToApply.Variables.Remove(ctxToApply.Variables.FirstOrDefault(v => v.Name.Equals(Name))); } } VariableContextLogic.Instance.Save(); } else { base.Out.Standard.WriteLine("The variable was NOT deleted."); } }
public abstract void Invoke(CommandInvocationContext context);