示例#1
0
        /// <exception cref="FailedToSpawnDaemon" />
        /// <exception cref="FailedToConnectToDaemon" />
        /// <exception cref="FailedToGreetDaemon" />
        /// <exception cref="FailedToCreateOutputDir"></exception>
        public void Preview(PreviewArguments args)
        {
            _fuse.Report.Info("Starting preview for " + args.Project + ", target " + args.Target, ReportTo.LogAndUser);

            if (args.PrintUnoConfig)
            {
                UnoConfigCommand.PrintUnoConfig(UnoConfig.Current, _textWriter);
            }

            if (args.Target == PreviewTarget.Local)
            {
                LaunchDesignerAndSubscribe(args).Wait();
                return;
            }

            var client = GetMessagingService(args).ToObservable().Switch();

            _exportedPreview.BuildAndRunExported(args, client, _shell, _fuse);
        }
示例#2
0
        public static int Run(List <string> args)
        {
            var fuse = FuseApi.Initialize("Fuse", args);

            Log = fuse.Report;

            Log.Info("Version " + fuse.Version);

            if (args.Contains("--version"))
            {
                Console.Out.WriteVersion(fuse.Version);
                return(0);
            }

            // Launch services adds -psn_something to the programs argument list
            // After moving an app from a dmg, and then starting the app
            var psnArgIdx = args.FindIndex(str => str.StartsWith("-psn"));

            if (psnArgIdx >= 0)
            {
                args.RemoveAt(psnArgIdx);
            }

            if (Platform.OperatingSystem == OS.Mac)
            {
                SetMinimumThreads(6);                 // For faster task creation in Mono. Mono doesn't have a good task system
            }
            var shell = new Shell();

            if (fuse.IsInstalled && shell.IsInsideRepo(AbsoluteDirectoryPath.Parse(Directory.GetCurrentDirectory())))
            {
                Log.Error("Please don't run installed Fuse from inside the Fuse repository. It will get confused by .unoconfigs.", ReportTo.LogAndUser);
                return(1);
            }

            var program =
                new CliProgram(
                    Log,
                    ColoredTextWriter.Out,
                    ColoredTextWriter.Error,
                    FuseCommandName,
                    () =>
            {
                MoveSdkConfigTmpBackCompatibleThing(shell);
            },
                    DashboardCommand.CreateDashboardCommand(),
                    OpenCommand.CreateOpenCommand(),
                    new LazyCliCommand("daemon", "Start the fuse daemon", false, () => DaemonCommand.CreateDaemonCommand()),
                    new LazyCliCommand("daemon-client", "Create a connection to a daemon.", false, () => DaemonClientCommand.Create()),
                    new LazyCliCommand("preview", "Preview an app", false, () => PreviewCommand.CreatePreviewCommand()),
                    new LazyCliCommand("build", "Build a project for a given target", false, () => BuildCommand.CreateBuildCommand()),
                    new LazyCliCommand("create", "Create a project or file from a template", false, () => CreateCommand.CreateCreateCommand()),
                    new LazyCliCommand("install", "Install an external component", false, () => InstallCommand.CreateInstallCommand()),
                    new LazyCliCommand("event-viewer", "Dump all events", true, () => EventViewerCommand.CreateEventViewerCommand()),
                    new LazyCliCommand("tutorial", "Go to tutorials and guides", false, () => TutorialCommand.CreateTutorialCommand()),
                    new LazyCliCommand("import", "Import a file to your fuse project", false, () => ImportCommand.CreateImportCommand()),
                    new LazyCliCommand("reset-preview", "Causes all active previews to reset to the default state.", true, () => ResetPreviewCliCommand.CreateResetPreviewCommand()),
                    new LazyCliCommand("kill-all", "Kill all Fuse processes (even the daemon)", false, () => KillAllCommand.CreateKillAllCommand()),
                    new LazyCliCommand("unoconfig", "Print uno config", false, () => UnoConfigCommand.CreateUnoConfigCommand()));

            var ctSource = new CancellationTokenSource();

            Console.CancelKeyPress += (sender, eventArgs) => ctSource.Cancel();

            return(program.Main(args.ToArray(), ctSource.Token));
        }