コード例 #1
0
        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);
                }
            }
        }
コード例 #2
0
        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);
            }
        }
コード例 #3
0
        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);
            }
        }
コード例 #4
0
 /// <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))));
 }