public ProgramConfiguration(ProgramArguments args)
        {
            outputFile = args.HasVariable("out") ? args.GetVariable("out") : null;
            templateFile = args.HasVariable("template") ? args.GetVariable("template") : args.HasVariable("template:debug") ? args.GetVariable("template:debug") : null;

            NoGui = args.CheckFlag("nogui");
            AutoOpenBrowser = args.CheckFlag("openbrowser");
            CloseOnFinish = args.CheckFlag("autoclose");
            IsDebuggingProject = args.HasVariable("debug");
            IsDebuggingTemplate = args.HasVariable("template:debug");

            if (args.CheckFlag("in:dummy")){
                inputType = InputType.Dummy;
            }
            else if (args.HasVariable("in:folder")){
                inputType = InputType.Folder;
                inputValue = args.GetVariable("in:folder");
            }
            else if (args.HasVariable("in:archive")){
                inputType = InputType.Archive;
                inputValue = args.GetVariable("in:archive");
            }
            else if (args.HasVariable("in:github")){
                inputType = InputType.GitHub;
                inputValue = args.GetVariable("in:github");
            }
        }
        public static bool Validate(ProgramArguments.Argument argument, Action<string> setError)
        {
            switch(argument.Name){
                case "nogui":
                case "openbrowser":
                case "autoclose":
                case "debug":
                case "in:dummy":
                    return true;

                case "template":
                case "template:debug":
                case "in:folder":
                case "in:archive":
                case "in:github":
                case "out":
                    if (argument.IsFlag){
                        setError(Lang.Get["ErrorInvalidArgsShouldBeVariable", argument.Name]);
                        return false;
                    }

                    if (argument.Name == "in:folder"){
                        if (!DirectoryIO.Exists(argument.Value)){
                            setError(Lang.Get["ErrorInvalidArgsFileNotFound", argument.Value]);
                            return false;
                        }
                    }
                    else if (argument.Name == "in:archive"){
                        if (!FileIO.Exists(argument.Value)){
                            setError(Lang.Get["ErrorInvalidArgsFileNotFound", argument.Value]);
                            return false;
                        }
                    }
                    else if (argument.Name == "in:github"){
                        if (!GitHub.IsRepositoryValid(argument.Value)){
                            setError(Lang.Get["ErrorInvalidArgsGitHub", argument.Value]);
                            return false;
                        }
                    }

                    return true;
            }

            setError(Lang.Get["ErrorInvalidArgsUnknown", argument.Name]);
            return false;
        }
Example #3
0
        private static void Main(string[] args)
        {
            Application.EnableVisualStyles();

            #if WINDOWS
            if (IsRunningMono()){
                MessageBox.Show(Lang.Get["ErrorLaunchMonoOnWindowsBuild"], Lang.Get["ErrorLaunchTitle"], MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            #endif

            ProgramArguments programArgs = new ProgramArguments(args, ProgramConfiguration.Validate);

            if (programArgs.HasError){
                MessageBox.Show(programArgs.Error, Lang.Get["ErrorInvalidArgsTitle"], MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            Config = new ProgramConfiguration(programArgs);
            Start();

            IOUtils.CleanupTemporaryDirectory();
        }