Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ private static string FormatResponse(ParseResult parseResult, global::ModernMT.I
static partial void CustomizeResponseFormatHints(Dictionary<string, CliFormatHint> hints);


static partial void CustomizeCommand(ref Command command);

public static Command Create()
{
var command = new Command(@"add-content", @"Add content to a translation memory");
Expand Down Expand Up @@ -152,6 +154,7 @@ await CliRuntime.WriteResponseAsync(
FormatResponse,
cancellationToken).ConfigureAwait(false);
}, cancellationToken).ConfigureAwait(false));
CustomizeCommand(ref command);
return command;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ private static string FormatResponse(ParseResult parseResult, global::ModernMT.I
static partial void CustomizeResponseFormatHints(Dictionary<string, CliFormatHint> hints);


static partial void CustomizeCommand(ref Command command);

public static Command Create()
{
var command = new Command(@"add-glossary", @"Add glossary terms to a memory");
Expand Down Expand Up @@ -123,6 +125,7 @@ await CliRuntime.WriteResponseAsync(
FormatResponse,
cancellationToken).ConfigureAwait(false);
}, cancellationToken).ConfigureAwait(false));
CustomizeCommand(ref command);
return command;
}
}
5 changes: 4 additions & 1 deletion src/cli/ModernMT.CLI/Commands/ApiCommand.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@

namespace ModernMT.CLI.Commands;

internal static class ApiCommand
internal static partial class ApiCommand
{
static partial void CustomizeCommand(ref Command command);

public static Command Create()
{
var command = new Command("api", "Generated endpoint commands.");

command.Subcommands.Add(DefaultApiGroupCommand.Create());
CustomizeCommand(ref command);
return command;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ private static string FormatResponse(ParseResult parseResult, global::ModernMT.M
static partial void CustomizeResponseFormatHints(Dictionary<string, CliFormatHint> hints);


static partial void CustomizeCommand(ref Command command);

public static Command Create()
{
var command = new Command(@"create-memory", @"Create a translation memory");
Expand Down Expand Up @@ -112,6 +114,7 @@ await CliRuntime.WriteResponseAsync(
FormatResponse,
cancellationToken).ConfigureAwait(false);
}, cancellationToken).ConfigureAwait(false));
CustomizeCommand(ref command);
return command;
}
}
5 changes: 4 additions & 1 deletion src/cli/ModernMT.CLI/Commands/DefaultApiGroupCommand.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@

namespace ModernMT.CLI.Commands;

internal static class DefaultApiGroupCommand
internal static partial class DefaultApiGroupCommand
{
static partial void CustomizeCommand(ref Command command);

public static Command Create()
{
var command = new Command(@"default", @"default endpoint commands.");
Expand All @@ -23,6 +25,7 @@ public static Command Create()
command.Subcommands.Add(TranslateCommandApiCommand.Create());
command.Subcommands.Add(TranslateBatchCommandApiCommand.Create());
command.Subcommands.Add(UpdateMemoryCommandApiCommand.Create());
CustomizeCommand(ref command);
return command;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ private static string FormatResponse(ParseResult parseResult, global::ModernMT.M
static partial void CustomizeResponseFormatHints(Dictionary<string, CliFormatHint> hints);


static partial void CustomizeCommand(ref Command command);

public static Command Create()
{
var command = new Command(@"delete-memory", @"Delete a translation memory");
Expand All @@ -58,6 +60,7 @@ await CliRuntime.WriteResponseAsync(
FormatResponse,
cancellationToken).ConfigureAwait(false);
}, cancellationToken).ConfigureAwait(false));
CustomizeCommand(ref command);
return command;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ private static string FormatResponse(ParseResult parseResult, global::ModernMT.D
static partial void CustomizeResponseFormatHints(Dictionary<string, CliFormatHint> hints);


static partial void CustomizeCommand(ref Command command);

public static Command Create()
{
var command = new Command(@"detect-language", @"Detect language of text");
Expand Down Expand Up @@ -104,6 +106,7 @@ await CliRuntime.WriteResponseAsync(
FormatResponse,
cancellationToken).ConfigureAwait(false);
}, cancellationToken).ConfigureAwait(false));
CustomizeCommand(ref command);
return command;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ private static string FormatResponse(ParseResult parseResult, global::ModernMT.C
static partial void CustomizeResponseFormatHints(Dictionary<string, CliFormatHint> hints);


static partial void CustomizeCommand(ref Command command);

public static Command Create()
{
var command = new Command(@"get-context-vector", @"Generate context vector for adaptive translation");
Expand Down Expand Up @@ -133,6 +135,7 @@ await CliRuntime.WriteResponseAsync(
FormatResponse,
cancellationToken).ConfigureAwait(false);
}, cancellationToken).ConfigureAwait(false));
CustomizeCommand(ref command);
return command;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ private static string FormatResponse(ParseResult parseResult, global::ModernMT.I
static partial void CustomizeResponseFormatHints(Dictionary<string, CliFormatHint> hints);


static partial void CustomizeCommand(ref Command command);

public static Command Create()
{
var command = new Command(@"get-import-job", @"Get import job status");
Expand All @@ -58,6 +60,7 @@ await CliRuntime.WriteResponseAsync(
FormatResponse,
cancellationToken).ConfigureAwait(false);
}, cancellationToken).ConfigureAwait(false));
CustomizeCommand(ref command);
return command;
}
}
3 changes: 3 additions & 0 deletions src/cli/ModernMT.CLI/Commands/GetMemoryCommandApiCommand.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ private static string FormatResponse(ParseResult parseResult, global::ModernMT.M
static partial void CustomizeResponseFormatHints(Dictionary<string, CliFormatHint> hints);


static partial void CustomizeCommand(ref Command command);

public static Command Create()
{
var command = new Command(@"get-memory", @"Get a translation memory");
Expand All @@ -58,6 +60,7 @@ await CliRuntime.WriteResponseAsync(
FormatResponse,
cancellationToken).ConfigureAwait(false);
}, cancellationToken).ConfigureAwait(false));
CustomizeCommand(ref command);
return command;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ private static string FormatResponse(ParseResult parseResult, global::ModernMT.L
static partial void CustomizeResponseFormatHints(Dictionary<string, CliFormatHint> hints);


static partial void CustomizeCommand(ref Command command);

public static Command Create()
{
var command = new Command(@"list-languages", @"List supported languages");
Expand Down Expand Up @@ -62,6 +64,7 @@ await CliRuntime.WriteResponseAsync(
cancellationToken).ConfigureAwait(false);
}
}, cancellationToken).ConfigureAwait(false));
CustomizeCommand(ref command);
return command;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ private static string FormatResponse(ParseResult parseResult, global::ModernMT.M
static partial void CustomizeResponseFormatHints(Dictionary<string, CliFormatHint> hints);


static partial void CustomizeCommand(ref Command command);

public static Command Create()
{
var command = new Command(@"list-memories", @"List translation memories");
Expand Down Expand Up @@ -62,6 +64,7 @@ await CliRuntime.WriteResponseAsync(
cancellationToken).ConfigureAwait(false);
}
}, cancellationToken).ConfigureAwait(false));
CustomizeCommand(ref command);
return command;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ private static string FormatResponse(ParseResult parseResult, global::ModernMT.Q
static partial void CustomizeResponseFormatHints(Dictionary<string, CliFormatHint> hints);


static partial void CustomizeCommand(ref Command command);

public static Command Create()
{
var command = new Command(@"quality-estimation", @"Estimate translation quality");
Expand Down Expand Up @@ -89,6 +91,7 @@ await CliRuntime.WriteResponseAsync(
FormatResponse,
cancellationToken).ConfigureAwait(false);
}, cancellationToken).ConfigureAwait(false));
CustomizeCommand(ref command);
return command;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ private static string FormatResponse(ParseResult parseResult, global::ModernMT.B
static partial void CustomizeResponseFormatHints(Dictionary<string, CliFormatHint> hints);


static partial void CustomizeCommand(ref Command command);

public static Command Create()
{
var command = new Command(@"translate-batch", @"Submit batch translation");
Expand Down Expand Up @@ -152,6 +154,7 @@ await CliRuntime.WriteResponseAsync(
FormatResponse,
cancellationToken).ConfigureAwait(false);
}, cancellationToken).ConfigureAwait(false));
CustomizeCommand(ref command);
return command;
}
}
3 changes: 3 additions & 0 deletions src/cli/ModernMT.CLI/Commands/TranslateCommandApiCommand.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ private static string FormatResponse(ParseResult parseResult, global::ModernMT.T
static partial void CustomizeResponseFormatHints(Dictionary<string, CliFormatHint> hints);


static partial void CustomizeCommand(ref Command command);

public static Command Create()
{
var command = new Command(@"translate", @"Translate text");
Expand Down Expand Up @@ -165,6 +167,7 @@ await CliRuntime.WriteResponseAsync(
FormatResponse,
cancellationToken).ConfigureAwait(false);
}, cancellationToken).ConfigureAwait(false));
CustomizeCommand(ref command);
return command;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ private static string FormatResponse(ParseResult parseResult, global::ModernMT.M
static partial void CustomizeResponseFormatHints(Dictionary<string, CliFormatHint> hints);


static partial void CustomizeCommand(ref Command command);

public static Command Create()
{
var command = new Command(@"update-memory", @"Update a translation memory");
Expand Down Expand Up @@ -112,6 +114,7 @@ await CliRuntime.WriteResponseAsync(
FormatResponse,
cancellationToken).ConfigureAwait(false);
}, cancellationToken).ConfigureAwait(false));
CustomizeCommand(ref command);
return command;
}
}
11 changes: 9 additions & 2 deletions src/cli/ModernMT.CLI/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,12 @@ dotnet tool install --global ModernMT.CLI --prerelease

```bash
modern-mt --help
modern-mt api --help
```
modern-mt default --help
```

## Customization

Generated operation, tag, and API group command classes are partial. Implement
`static partial void CustomizeCommand(ref Command command)` in a separate source
file to add aliases or validators, change the action, or replace a command. The
hook runs after the generated command has been configured.
Loading