public override void DoExecute(CommandArgs args) { var databaseName = args.Arguments[0]; var connectionData = Settings.GetConnection(databaseName); var viewVersionTask = TaskFactory.CreateViewDbVersionTask(connectionData); viewVersionTask.ViewVersion(); }
public override void DoExecute(CommandArgs args) { if (!args.HasArguments) { ViewSettings(); return; } TrySet(args); }
public void Execute(IList<string> args) { var commandArgs = new CommandArgs(args); if (!AreValid(commandArgs) || commandArgs.Help) { Logger.WriteLine(GenerateUsageText()); return; } DoExecute(commandArgs); }
public override void DoExecute(CommandArgs args) { var populateContextTask = TaskFactory.CreatePopulateContextTask(Settings.DefaultConnection); var overwriteExisting = args.Flags.Contains(Overwrite); var databases = args.Arguments; if (databases.Any()) { populateContextTask.Populate(databases, overwriteExisting); } else { populateContextTask.PopulateAll(overwriteExisting); } }
public override void DoExecute(CommandArgs args) { var connectionData = Settings.GetConnection(args.Arguments[0]); var parameters = new BackupParameters { DatabaseName = connectionData.Name, FilePath = args.Arguments[1], Server = connectionData.Host }; var restoreTask = TaskFactory.CreateRestoreTask(connectionData); restoreTask.PercentComplete += PrintPercentage; restoreTask.Complete += TaskComplete; restoreTask.Restore(parameters); }
public override void DoExecute(CommandArgs args) { if (!args.HasArguments) { PrintContexts(); return; } if (!args.HasFlags) { SwitchContextTo(args.Arguments[0]); } else { HandleContext(args); } }
private void TrySet(CommandArgs args) { var split = args.Arguments[0].Split(':'); if (split.Length < 2) { throw new DbToolException(string.Format("Invalid parameter {0}", args.Arguments[0])); } var key = split[0]; var value = split[1]; try { Settings.Set(key, value); } catch (Exception ex) { Logger.WriteLine("Could not set {0}: {1}", key, ex.Message); Logger.WriteLine("Try {0} {1} to view settings", Process.GetCurrentProcess().ProcessName, Name); } }
public void Ctor_ShouldSetFlags() { var args = new CommandArgs(ArgumentList(Some.Flag, Some.DoubleFlag)); MakeSure.ThatCollection(args.Flags).ContainsOnly(Some.Flag); }
public void Ctor_ShouldSetHelp_WhenThereIsHelpFlag() { var args = new CommandArgs(ArgumentList(CommandArgs.HelpFlag)); Assert.That(args.Help); }
public override bool AreValid(CommandArgs args) { return(args.HasArguments); }
public void Ctor_ShouldSetCommand() { var args = new CommandArgs(ArgumentList()); Assert.That(args.Command, Is.EqualTo(Some.Command)); }
public override void DoExecute(CommandArgs args) { var listDbTask = TaskFactory.CreateListDbTask(Settings.DefaultConnection); var showAll = args.Flags.Contains("-a"); listDbTask.ListDatabases(showAll); }
public override bool AreValid(CommandArgs args) { return true; }
public override bool AreValid(CommandArgs args) { return(true); }
public override void DoExecute(CommandArgs args) { Logger.WriteLine(DbToolValues.Version); }
public void HasArguments_ShouldBeFalse_WhenThereIsNoArgument() { var args = new CommandArgs(ArgumentList(Some.Flag, Some.DoubleFlag)); Assert.That(args.HasArguments, Is.False); }
public void HasFlags_ShouldBeFalse_WhenThereIsNoFlag() { var args = new CommandArgs(ArgumentList(Some.Argument)); Assert.That(args.HasFlags, Is.False); }
public override bool AreValid(CommandArgs args) { return !(args.HasFlags && !args.HasArguments); }
public abstract void DoExecute(CommandArgs args);
public abstract bool AreValid(CommandArgs args);
private static string GetBackupPath(CommandArgs args) { return args.Arguments.Count > 1 ? args.Arguments[1] : string.Empty; }
public override bool AreValid(CommandArgs args) { return args.Arguments.Count > 0 && !string.IsNullOrWhiteSpace(args.Arguments[0]); }
public void HasArguments_ShouldBeTrue_WhenThereIsArgument() { var args = new CommandArgs(ArgumentList(Some.Argument)); Assert.That(args.HasArguments); }
private void HandleContext(CommandArgs args) { var flag = args.Flags.First(); switch(flag) { case AddFlag: CreateContext(args.Arguments[0]); break; case DeleteFlag: DeleteContext(args.Arguments[0]); break; default: Logger.WriteLine("Unknown flag {0}", flag); break; } }
public void HasFlags_ShouldBeTrue_WhenThereIsFlag() { var args = new CommandArgs(ArgumentList(Some.Flag)); Assert.That(args.HasFlags); }
public override bool AreValid(CommandArgs args) { return(args.Arguments.Count > 0 && !string.IsNullOrWhiteSpace(args.Arguments[0])); }
public override bool AreValid(CommandArgs args) { return args.HasArguments && args.Arguments.Count > 1; }
private static string GetBackupPath(CommandArgs args) { return(args.Arguments.Count > 1 ? args.Arguments[1] : string.Empty); }
public override bool AreValid(CommandArgs args) { return args.HasArguments; }
public override bool AreValid(CommandArgs args) { return(!(args.HasFlags && !args.HasArguments)); }
public void Ctor_ShouldNotSetHelp_WhenThereIsNoHelpFlag() { var args = new CommandArgs(ArgumentList(Some.Argument, Some.Flag, Some.DoubleFlag)); Assert.That(args.Help, Is.False); }
public void Ctor_ShouldSetArguments() { var args = new CommandArgs(ArgumentList(Some.Argument, Some.OtherArgument)); MakeSure.ThatCollection(args.Arguments).ContainsOnly(Some.Argument, Some.OtherArgument); }
public override void DoExecute(CommandArgs args) { var databaseName = args.Arguments[0]; var deleteDbTask = TaskFactory.CreateDeleteDbTask(Settings.DefaultConnection); deleteDbTask.Delete(databaseName); }