private void Remove() { if (AdditionalArgs.Count < 2) { throw new OptionException(Resources.MissingArguments + Environment.NewLine + "remove DIGEST+", ""); } foreach (var digest in AdditionalArgs.Skip(1).Select(x => new ManifestDigest(x))) { if (!Store.Remove(digest, Handler)) { throw new ImplementationNotFoundException(digest); } } }
public override ExitCode Execute() { var manifestDigest = new ManifestDigest(AdditionalArgs[0]); string path = AdditionalArgs[1]; try { if (File.Exists(path)) { // One or more archives (combined/overlay) ImplementationStore.Add(manifestDigest, BuildImplementation); return(ExitCode.OK); } else if (Directory.Exists(path)) { // A single directory if (AdditionalArgs.Count > 2) { throw new OptionException(Resources.TooManyArguments + Environment.NewLine + AdditionalArgs.Skip(2).JoinEscapeArguments(), null); } ImplementationStore.Add(manifestDigest, builder => Handler.RunTask(new ReadDirectory(Path.GetFullPath(path), builder))); return(ExitCode.OK); } else { throw new FileNotFoundException(string.Format(Resources.FileOrDirNotFound, path), path); } } catch (ImplementationAlreadyInStoreException ex) { Log.Warn(ex); return(ExitCode.NoChanges); } }
public override ExitCode Execute() { var manifestDigest = new ManifestDigest(AdditionalArgs[0]); try { string path = AdditionalArgs[1]; if (Directory.Exists(path)) { if (AdditionalArgs.Count > 2) { throw new OptionException(Resources.TooManyArguments + Environment.NewLine + AdditionalArgs.Skip(2).JoinEscapeArguments(), null); } ImplementationStore.Add(manifestDigest, builder => Handler.RunTask(new ReadDirectory(Path.GetFullPath(path), builder))); return(ExitCode.OK); } ImplementationStore.Add(manifestDigest, BuildImplementation); return(ExitCode.OK); } catch (ImplementationAlreadyInStoreException ex) { Log.Warn(ex.Message, ex); return(ExitCode.NoChanges); } }
/// <summary> /// Returns the default <see cref="IStore"/> or a <see cref="CompositeStore"/> as specifief by the <see cref="CliCommand.AdditionalArgs"/>. /// </summary> private IStore GetStore() { return((AdditionalArgs.Count == 1) ? Store : new CompositeStore(AdditionalArgs.Skip(1).Select(arg => (IStore) new DirectoryStore(arg)))); }