コード例 #1
0
ファイル: Program.cs プロジェクト: hibri/Mint
        private static Arguments ValidateArgs(string[] args)
        {
            ArgumentsAdapter argumentsAdapter = new ArgumentsAdapter(args);

            Unless(argumentsAdapter.AreValid, () =>
                                              DieBecause("Incorrect arguments, usage: ", argumentsAdapter.Usage)
                );

            string argument = argumentsAdapter.Get(ArgumentsAdapter.Names.Command);
            string workingDirectory = argumentsAdapter.Get(ArgumentsAdapter.Names.WorkingDirectory);
            string assemblyName = argumentsAdapter.Get(ArgumentsAdapter.Names.AssemblyName);

            Unless(Directory.Exists(workingDirectory), () =>
                                                       DieBecause("The library directory could not be found: <{0}>", workingDirectory)
                );

            Unless(Command.Exists(argument), () =>
                                             DieBecause("The command is invalid: {0}", argument)
                );

            return new Arguments(argument,workingDirectory,assemblyName);
        }
コード例 #2
0
ファイル: Application.cs プロジェクト: hibri/Mint
        private static ValidationResult<Arguments> Validate(String[] args)
        {
            ArgumentsAdapter arguments = new ArgumentsAdapter(args);

            if (false == arguments.IsValid)
                return ValidationResult<Arguments>.FailedBecause(
                    "Incorrect arguments, usage: {0} {1}",
                    EXECUTABLE,
                    arguments.Usage
                );

            var command				= arguments[Name.Command];
            var workingDirectory	= arguments[Name.WorkingDirectory];
            var assemblyName		= arguments[Name.AssemblyName];

            if (false == Directory.Exists(workingDirectory))
                return ValidationResult<Arguments>.FailedBecause(
                    "The working directory could not be found: <{0}>", workingDirectory
                );

            if (false == Commands.Contains(command))
                return ValidationResult<Arguments>.FailedBecause(
                    "The command is invalid: <{0}>", command
                );

            return ValidationResult<Arguments>.Succeeded(
                new Arguments(
                    command,
                    workingDirectory,
                    assemblyName
                ) { Log = Log }
            );
        }