Skip to content

Commit

Permalink
Describe targets.
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastianStehle committed Feb 10, 2023
1 parent 9afd5b7 commit 73328ec
Show file tree
Hide file tree
Showing 12 changed files with 30 additions and 8 deletions.
2 changes: 1 addition & 1 deletion cli/Squidex.CLI/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
<PackageTags>Squidex HeadlessCMS</PackageTags>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<Version>9.2</Version>
<Version>9.3</Version>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ public sealed class AppSynchronizer : ISynchronizer

public string Name => "App";

public string Description => "Synchronize all app settings: clients, contributors, roles, languages and asset scripts. But not: workflows.";

public AppSynchronizer(ILogger log)
{
this.log = log;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ public sealed class AssetFoldersSynchronizer : ISynchronizer

public string Name => "AssetFolders";

public string Description => "Synchronizes all asset folders, even if they do not contain assets.";

public AssetFoldersSynchronizer(ILogger log)
{
this.log = log;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ public sealed class AssetsSynchronizer : ISynchronizer

public string Name => "Assets";

public string Description => "Synchronizes all assets and creates asset folders if they do not exist yet.";

public AssetsSynchronizer(ILogger log)
{
this.log = log;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ public sealed class ContentsSynchronizer : ISynchronizer

public string Name => "Contents";

public string Description => "Synchronizes all content items across all schemas.";

public ContentsSynchronizer(ILogger log)
{
this.log = log;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ public interface ISynchronizer

string Name { get; }

string Description { get; }

Task CleanupAsync(IFileSystem fs);

Task DescribeAsync(ISyncService sync, MarkdownWriter writer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ internal sealed class RuleModel
public DynamicRuleAction Action { get; set; }

[JsonIgnore]
public RuleAction TypedAction
public RuleActionDto TypedAction
{
set
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ public sealed class RulesSynchronizer : ISynchronizer

public string Name => "Rules";

public string Description => "Synchronizes all rules, but not rule events.";

public RulesSynchronizer(ILogger log)
{
this.log = log;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public sealed class SchemasSynchronizer : ISynchronizer

public string Name => "Schemas";

public string Description => "Synchronizes all schemas, but not the content.";

public SchemasSynchronizer(ILogger log)
{
this.log = log;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ public Synchronizer(IEnumerable<ISynchronizer> synchronizers, ILogger log)
this.log = log;
}

public IEnumerable<string> GetTargets()
public IEnumerable<(string Name, string Description)> GetTargets()
{
return GetSynchronizers().Select(x => x.Name);
return GetSynchronizers().Select(x => (x.Name, x.Description));
}

public async Task Describe(string path, ISession session)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ public sealed class WorkflowsSynchronizer : ISynchronizer

public string Name => "Workflows";

public string Description => "Synchronizes all workflows from the app settings.";

public WorkflowsSynchronizer(ILogger log)
{
this.log = log;
Expand Down
14 changes: 10 additions & 4 deletions cli/Squidex.CLI/Squidex.CLI/Commands/App_Sync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@
// ==========================================================================

using CommandDotNet;
using ConsoleTables;
using FluentValidation;
using Squidex.CLI.Commands.Implementation;
using Squidex.CLI.Commands.Implementation.Sync;
using Squidex.CLI.Commands.Implementation.Utils;
using Squidex.CLI.Configuration;
using static Squidex.CLI.Commands.App;

namespace Squidex.CLI.Commands;

Expand Down Expand Up @@ -80,10 +82,14 @@ public async Task Describe(DescribeArguments arguments)
[Command("targets", Description = "List all targets.")]
public void Targets()
{
foreach (var target in synchronizer.GetTargets())
var table = new ConsoleTable("Name", "Description");

foreach (var (name, description) in synchronizer.GetTargets())
{
log.WriteLine("- {0}", target.ToLowerInvariant());
table.AddRow(name.ToLowerInvariant(), description);
}

table.Write();
}

public sealed class NewArgument : AppArguments
Expand All @@ -105,7 +111,7 @@ public sealed class InArguments : AppArguments
[Operand("folder", Description = "The target folder to synchronize.")]
public string Folder { get; set; }

[Option('t', "targets", Description = "The targets to sync, e.g. schemas, workflows, app, rules.")]
[Option('t', "targets", Description = "The targets to sync, e.g. 'contents' or 'schemas'. Use 'sync targets' to view all targets.")]
public string[] Targets { get; set; }

[Option("language", Description = "The content language to synchronize.")]
Expand Down Expand Up @@ -158,7 +164,7 @@ public sealed class OutArguments : AppArguments
[Operand("folder", Description = "The target folder to synchronize.")]
public string Folder { get; set; }

[Option('t', "targets", Description = "The targets to sync, e.g. schemas, workflows, app, rules, contents.")]
[Option('t', "targets", Description = "The targets to sync, e.g. 'contents' or 'schemas'. Use 'sync targets' to view all targets.")]
public string[] Targets { get; set; }

[Option("describe", Description = "Create a README.md file.")]
Expand Down

0 comments on commit 73328ec

Please sign in to comment.