示例#1
0
        public async Task Describe(string path, ISession session)
        {
            using (var fs = await FileSystems.CreateAsync(path, session.WorkingDirectory))
            {
                if (!fs.CanWrite)
                {
                    Console.WriteLine("ERROR: Cannot write to the file system.");
                    return;
                }

                var sync = new SyncService(fs, session);

                var readme = fs.GetFile(new FilePath("README.md"));

                await using (var file = readme.OpenWrite())
                {
                    await using (var textWriter = new StreamWriter(file))
                    {
                        var markdown = new MarkdownWriter(textWriter);

                        markdown.H1($"Export {DateTime.UtcNow}");

                        markdown.Paragraph("--- Describe your export here ---");
                        markdown.Paragraph("Usage");

                        markdown.Code(
                            "// Add a config to your app.",
                            "sq config add <APP> <CLIENT_ID> <CLIENT_SECRET>",
                            string.Empty,
                            "// Switch to your app.",
                            "sq config use <APP>",
                            string.Empty,
                            "// Import this folder",
                            "sq sync in <PATH_TO_THIS_FOLDER");

                        foreach (var synchronizer in synchronizers)
                        {
                            markdown.H2(synchronizer.Name);

                            await synchronizer.DescribeAsync(sync, markdown);
                        }
                    }
                }
            }
        }
示例#2
0
        public async Task GenerateTemplateAsync(string path)
        {
            using (var fs = FileSystems.Create(path))
            {
                if (!fs.CanWrite)
                {
                    Console.WriteLine("ERROR: Cannot write to the file system.");
                    return;
                }

                var sync = new SyncService(fs);

                foreach (var synchronizer in GetSynchronizers())
                {
                    await synchronizer.GenerateSchemaAsync(sync);
                }
            }
        }
示例#3
0
        public async Task ExportAsync(string path, SyncOptions options, ISession session)
        {
            using (var fs = FileSystems.Create(path))
            {
                if (!fs.CanWrite)
                {
                    Console.WriteLine("ERROR: Cannot write to the file system.");
                    return;
                }

                var selectedSynchronizers = GetSynchronizers(options.Targets);
                var selectedCount         = selectedSynchronizers.Count;

                WriteSummary(fs, selectedSynchronizers);

                var sync = new SyncService(fs);

                foreach (var synchronizer in selectedSynchronizers)
                {
                    await synchronizer.GenerateSchemaAsync(sync);
                }

                await selectedSynchronizers.Foreach(async (synchronizer, step) =>
                {
                    log.WriteLine();
                    log.WriteLine("--------------------------------------------------------");
                    log.WriteLine("* STEP {0} of {1}: Exporting {2} started", step, selectedCount, synchronizer.Name);
                    log.WriteLine();

                    await synchronizer.CleanupAsync(fs);
                    await synchronizer.ExportAsync(sync, options, session);

                    log.WriteLine();
                    log.WriteLine("* STEP {0} of {1}: Exporting {2} completed", step, selectedSynchronizers.Count, synchronizer.Name);
                    log.WriteLine("--------------------------------------------------------");
                });
            }
        }