mirror of
https://github.com/Yuyi-Oak/BlueArchiveToolkit.git
synced 2026-09-18 10:54:55 +08:00
@@ -8,18 +8,19 @@ use bat_infrastructure::DEFAULT_DOWNLOAD_CONCURRENCY;
|
||||
use bat_infrastructure::{
|
||||
apply_patch_file, apply_unityfs_field_patch_file, apply_unityfs_string_field_patch_file,
|
||||
apply_unityfs_text_asset_patch_file, changed_endpoint_urls, diff_extended_snapshot,
|
||||
export_translation_workbench, gc_orphan_staging, lexical_absolute,
|
||||
export_translation_workbench, gc_orphan_staging, get_translation_entry, lexical_absolute,
|
||||
localized_text_asset_patches, open_append_file, read_download_manifest_at,
|
||||
read_file_no_symlink, read_localized_patch_manifest_at, read_localized_version_state,
|
||||
read_parse_cache_at, read_snapshot, read_textunit_index_at, read_translation_workbench,
|
||||
read_version_state, redact_proxy_url, repack_bundle, resolve_curl_proxy, set_translation,
|
||||
validate_output_root, validate_runtime_state_dir, validate_translation_workbench,
|
||||
write_file_atomic, write_official_textunit_queues, CurlProxyConfig, CurlProxyMode,
|
||||
LocalizedPatchConfig, LocalizedPatchReport, LocalizedPatchService, OfficialEndpointMarkerRole,
|
||||
OfficialFailedVersionRecord, OfficialParseCacheService, OfficialParseConfig,
|
||||
OfficialResourceHashVerification, OfficialResourceVerification, OfficialServerInfoSource,
|
||||
OfficialTextUnitQuery, OfficialTextUnitTaskQuery, OfficialUpdateConfig, OfficialUpdateProgress,
|
||||
OfficialUpdateReport, OfficialUpdateService, OfficialUpdateSnapshot, OfficialUpdateStatus,
|
||||
unset_translation, validate_output_root, validate_runtime_state_dir,
|
||||
validate_translation_workbench, write_file_atomic, write_official_textunit_queues,
|
||||
CurlProxyConfig, CurlProxyMode, LocalizedPatchConfig, LocalizedPatchReport,
|
||||
LocalizedPatchService, OfficialEndpointMarkerRole, OfficialFailedVersionRecord,
|
||||
OfficialParseCacheService, OfficialParseConfig, OfficialResourceHashVerification,
|
||||
OfficialResourceVerification, OfficialServerInfoSource, OfficialTextUnitQuery,
|
||||
OfficialTextUnitTaskQuery, OfficialUpdateConfig, OfficialUpdateProgress, OfficialUpdateReport,
|
||||
OfficialUpdateService, OfficialUpdateSnapshot, OfficialUpdateStatus,
|
||||
OfficialVerificationSummary, OfficialVersionRecord, OfficialVersionState, PatchApplyKind,
|
||||
PatchApplyParams, PatchApplyReport, ReleaseFlowStatusCode, RepackReport,
|
||||
SqliteResourceRepository, SqliteTranslationTaskRepository, TranslationTaskStatus,
|
||||
@@ -80,7 +81,8 @@ use translation_query::{
|
||||
};
|
||||
use workflow_commands::{
|
||||
run_parse_clear_cache, run_parse_once, run_publish_localized, run_repack, run_translate_once,
|
||||
run_translation_set, run_translation_task_update, run_translation_validate,
|
||||
run_translation_get, run_translation_set, run_translation_task_update, run_translation_unset,
|
||||
run_translation_validate,
|
||||
};
|
||||
|
||||
const EXIT_ERROR: i32 = 1;
|
||||
@@ -209,6 +211,14 @@ fn run() -> anyhow::Result<i32> {
|
||||
run_translation_set(&options)?;
|
||||
Ok(0)
|
||||
}
|
||||
CliCommand::TranslationGet => {
|
||||
run_translation_get(&options)?;
|
||||
Ok(0)
|
||||
}
|
||||
CliCommand::TranslationUnset => {
|
||||
run_translation_unset(&options)?;
|
||||
Ok(0)
|
||||
}
|
||||
CliCommand::TranslationTaskUpdate => {
|
||||
run_translation_task_update(&options)?;
|
||||
Ok(0)
|
||||
@@ -527,6 +537,8 @@ enum CliCommand {
|
||||
Translate,
|
||||
TranslationValidate,
|
||||
TranslationSet,
|
||||
TranslationGet,
|
||||
TranslationUnset,
|
||||
TranslationTaskUpdate,
|
||||
Repack,
|
||||
PublishLocalized,
|
||||
@@ -7207,12 +7219,58 @@ fn parse_args_with_env(
|
||||
options.progress = false;
|
||||
options.banner = false;
|
||||
}
|
||||
CliCommand::TranslationSet | CliCommand::Repack => {
|
||||
CliCommand::TranslationSet | CliCommand::TranslationGet | CliCommand::TranslationUnset => {
|
||||
if options.watch || options.daemon || options.daemon_child {
|
||||
return Err(anyhow::anyhow!("translation set/repack 只支持单次执行"));
|
||||
return Err(anyhow::anyhow!(
|
||||
"translation workbench 编辑命令只支持单次执行"
|
||||
));
|
||||
}
|
||||
if options.config.force || options.sync_option_explicit || options.run_count.is_some() {
|
||||
return Err(anyhow::anyhow!("translation set/repack 不接受资源同步选项"));
|
||||
return Err(anyhow::anyhow!(
|
||||
"translation workbench 编辑命令不接受资源同步选项"
|
||||
));
|
||||
}
|
||||
if options.translation_file.is_none() || options.translation_id.is_none() {
|
||||
return Err(anyhow::anyhow!(
|
||||
"translation workbench 编辑命令必须指定 --translation-file 和 --translation-id"
|
||||
));
|
||||
}
|
||||
if matches!(options.command, CliCommand::TranslationSet) {
|
||||
if options.translation_text.is_some() == options.translation_text_file.is_some() {
|
||||
return Err(anyhow::anyhow!(
|
||||
"i18n set 必须且只能指定 --translated-text 或 --translated-file"
|
||||
));
|
||||
}
|
||||
} else if options.translation_text.is_some() || options.translation_text_file.is_some()
|
||||
{
|
||||
return Err(anyhow::anyhow!(
|
||||
"i18n get/unset 不接受 --translated-text 或 --translated-file"
|
||||
));
|
||||
}
|
||||
if options.output_explicit
|
||||
|| options.resource_root.is_some()
|
||||
|| options.localized_release_id.is_some()
|
||||
|| options.repack_spec.is_some()
|
||||
|| options.query_option_explicit
|
||||
|| options.schedule_option_explicit
|
||||
|| options.translation_failure_reason.is_some()
|
||||
|| options.translation_provider_run_id.is_some()
|
||||
|| options.proxy_option_explicit
|
||||
|| tools_are_non_default(&options.config, &options.env_baseline_config)
|
||||
{
|
||||
return Err(anyhow::anyhow!(
|
||||
"translation workbench 编辑命令只接受 --translation-file、--translation-id、译文字段、--state-dir 和 --json/--human"
|
||||
));
|
||||
}
|
||||
options.progress = false;
|
||||
options.banner = false;
|
||||
}
|
||||
CliCommand::Repack => {
|
||||
if options.watch || options.daemon || options.daemon_child {
|
||||
return Err(anyhow::anyhow!("repack 只支持单次执行"));
|
||||
}
|
||||
if options.config.force || options.sync_option_explicit || options.run_count.is_some() {
|
||||
return Err(anyhow::anyhow!("repack 不接受资源同步选项"));
|
||||
}
|
||||
options.progress = false;
|
||||
options.banner = false;
|
||||
@@ -7461,10 +7519,15 @@ fn parse_translation_command(
|
||||
if action == "task" {
|
||||
return parse_translation_task_command(args, options);
|
||||
}
|
||||
if action == "workbench" || action == "wb" {
|
||||
return parse_translation_workbench_command(args, options);
|
||||
}
|
||||
let command = match action.as_str() {
|
||||
"run" => CliCommand::Translate,
|
||||
"export" => CliCommand::Translate,
|
||||
"set" => CliCommand::TranslationSet,
|
||||
"get" | "show" => CliCommand::TranslationGet,
|
||||
"unset" | "clear" => CliCommand::TranslationUnset,
|
||||
"validate" => CliCommand::TranslationValidate,
|
||||
"publish" => CliCommand::PublishLocalized,
|
||||
"tasks" => CliCommand::TranslationTasks,
|
||||
@@ -7481,6 +7544,28 @@ fn parse_translation_command(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn parse_translation_workbench_command(
|
||||
args: &mut impl Iterator<Item = String>,
|
||||
options: &mut CliOptions,
|
||||
) -> anyhow::Result<()> {
|
||||
let action = next_option_value(args, "translation workbench")?;
|
||||
let command = match action.as_str() {
|
||||
"export" => CliCommand::Translate,
|
||||
"set" => CliCommand::TranslationSet,
|
||||
"get" | "show" => CliCommand::TranslationGet,
|
||||
"unset" | "clear" => CliCommand::TranslationUnset,
|
||||
"validate" => CliCommand::TranslationValidate,
|
||||
other => {
|
||||
return Err(anyhow::anyhow!(
|
||||
"未知 translation workbench 二级命令:{other}"
|
||||
))
|
||||
}
|
||||
};
|
||||
ensure_command_not_set(options.command, &format!("translation workbench {action}"))?;
|
||||
options.command = command;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn parse_translation_task_command(
|
||||
args: &mut impl Iterator<Item = String>,
|
||||
options: &mut CliOptions,
|
||||
@@ -7606,6 +7691,8 @@ fn print_usage(binary: &str) {
|
||||
eprintln!(" i18n run Refresh offline translation work");
|
||||
eprintln!(" i18n export Export an editable translation workbench");
|
||||
eprintln!(" i18n set Update one translation workbench entry");
|
||||
eprintln!(" i18n get Show one translation workbench entry");
|
||||
eprintln!(" i18n unset Clear one translated workbench entry");
|
||||
eprintln!(" i18n validate Validate workbench against the current official release");
|
||||
eprintln!(" i18n task update Update one provider worker task status");
|
||||
eprintln!(" i18n publish Publish a localized release");
|
||||
@@ -7641,6 +7728,12 @@ fn print_usage(binary: &str) {
|
||||
eprintln!(" {binary} res pull --auto-discover --run-count 3 --interval 1h");
|
||||
eprintln!(" {binary} parse run --force --resource-root /tmp/bat-release");
|
||||
eprintln!(" {binary} i18n export --translation-file /tmp/bat-workbench.json");
|
||||
eprintln!(
|
||||
" {binary} i18n get --translation-file /tmp/bat-workbench.json --translation-id unit-1"
|
||||
);
|
||||
eprintln!(
|
||||
" {binary} i18n unset --translation-file /tmp/bat-workbench.json --translation-id unit-1"
|
||||
);
|
||||
eprintln!(" {binary} i18n publish --translation-file /tmp/bat-workbench.json --force");
|
||||
eprintln!(" {binary} status");
|
||||
eprintln!(" {binary} refresh --force --json");
|
||||
|
||||
Reference in New Issue
Block a user