From f4566aafa482c20026ef64f363542df4c30f59e2 Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Tue, 21 Oct 2025 21:48:23 +0800 Subject: Update locales files --- locales/help_docs/en.yml | 207 +++++++++++++++++++++++++++++++++++++++- locales/help_docs/zh-CN.yml | 227 +++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 429 insertions(+), 5 deletions(-) diff --git a/locales/help_docs/en.yml b/locales/help_docs/en.yml index df6ee2b..6092873 100644 --- a/locales/help_docs/en.yml +++ b/locales/help_docs/en.yml @@ -99,7 +99,7 @@ jvv: here: info: | Found vault *`%{name}`*! (%{num_mem} Members, %{num_pk} registered PubKeys) - Managing %{num_sheets} Sheets, %{num_vf} VirtualFiles, total %{total_size_gb} GB + Managing %{num_sheets} Sheets, %{num_vf} VirtualFiles, total %{total_size} **Tip**: To start the server, run jvv service listen @@ -123,3 +123,208 @@ jvv: service: listen: Listening for client connections in vault `%{path}` ... + +jv: + help: | + **JustEnoughVCS Local Workspace Commands** + This program connects to upstream vaults to synchronize and commit changes to local workspace files for collaborative work. + + **Common Aliases**: + jv u Download latest information, jv t Track files, jv mv -a Auto-move files, jv in/out Import or export files + + **Create Workspace**: + jv create - Create a workspace in the given directory name + jv init - Create a workspace in the current directory + + **Connect to Upstream Vault**: + jv direct - Direct your workspace to this vault + After specifying an upstream vault, your workspace will be *stained*, and you will not be able to connect to vaults with different identifiers + + jv unstain - Unstain your workspace (remove stain identifier), after which the workspace will be unrelated to any upstream vault + + **Account Management**: + jv account list - List all accounts on this computer and whether private keys are registered + jv account as - Switch current account + jv account add - Add an account to this computer + jv account remove - Delete this account + jv account mvkey - Move private key to specified account + + **Information Synchronization**: + jv update - Download latest information from upstream workspace + + **Sheet Operations**: + jv sheet list - List all sheets in the upstream workspace + jv sheet use - Use the specified sheet to start current work (automatically created if it doesn't exist) + jv sheet exit - Exit current work + + jv import - Import files from import area + jv import - Import files from reference sheet + jv export -m -n - Export specified file package to import area of other sheets + + **File Operations** + jv move - Safely rename files + jv move auto - Automatically handle local file moves or renames + jv track - Track and upload files to upstream vault + + **Query Built-in Documentation** + jv docs list - List all available documentation + jv docs - View content of specified documentation + or jv docs -e - Return temporary path of specific documentation for editor opening + **Example**: jv docs get-started -e | nano + + You can use jv --help to query more detailed help! + + **Tip**: If you need to understand JustEnoughVCS collaboration paradigms, use jv docs get-started + + account: | + **Manage Local Accounts** + **Usage**: + jv account list - List all accounts on this computer and whether private keys are registered + jv account as - Switch current account + jv account add - Add an account to this computer + jv account remove - Delete this account + jv account mvkey - Move private key to specified account + + Accounts are identity identifiers on the local computer, each account can be associated with different private keys. + You need to set up accounts before interacting with upstream vaults. + + sheet: | + **Manage File Sheets** + **Usage**: + jv sheet list - List all sheets in the upstream workspace + jv sheet use - Use the specified sheet to start current work (automatically created if it doesn't exist) + jv sheet exit - Exit current work + + Sheets are core concepts in JustEnoughVCS, each sheet represents an independent file collection. + You can switch work between different sheets, or export files from one sheet to another. + + create: | + **Create Workspace with Specified Name** + **Usage**: jv create + + **Example**: jv create my_workspace + Creates a directory named 'my_workspace' in the current directory and initializes a workspace inside it. + + Workspace is your local working environment for file synchronization and version control with upstream vaults. + + init: | + **Create Workspace in Current Directory** + **Usage**: jv init + + This command creates a workspace in the current directory, with the workspace name determined by the current directory name. + + If the current directory is not empty, this operation will fail. Please ensure you execute this command in an empty directory. + + here: | + **Query Directory Information Here** + **Usage**: jv here + + Displays detailed information about current directory files, including: + - File name, size, version number + - Current file holder + - Latest version commit information + + This is a quick way to understand the current state of your workspace directory. + + track: | + **Track Local Files** + **Usage**: jv track + + **Example**: jv track src/main.rs + First track - Create and upload the "First Version", then automatically hold them + Subsequent tracks - Update files with new versions + + Tracking files is the basic operation of version control, ensuring your changes can be synchronized to the upstream vault. + + hold: | + **Hold Files: Obtain File Edit Rights from Upstream Vault** + **Usage**: jv hold + + **Example**: jv hold src/lib.rs + When you need to edit a file, you must first hold the file's edit rights. + After holding a file, other collaborators will not be able to edit the same file simultaneously, avoiding conflicts. + + After editing, remember to track the file to save changes. + + throw: | + **Throw Files: Release File Edit Rights from Upstream Vault** + **Usage**: jv throw + + **Example**: jv throw src/config.rs + When you no longer need to edit a file, you can throw the file's edit rights. + After throwing, other collaborators can hold and edit the file. + + If you have made changes to the file but haven't tracked them, throwing will lose those changes. + + move: | + **Move Local Files** + **Usage**: + jv move - Safely rename or move files + jv move auto - Automatically handle local file moves or renames + + **Example**: + jv move old_name.txt new_name.txt + jv move src/old_dir/file.rs src/new_dir/file.rs + jv move auto + + Safe move operations preserve file version history, while auto-move detects and handles all renames. + + export: | + **Export Files to Import Area of Other Sheets** + **Usage**: jv export -m -n + + **Example**: jv export data.csv analytics -m "Export analysis data" -n "analysis_data" + This operation packages the specified files and sends them to the import area of the target sheet. + + Other collaborators can use the jv import command in the target sheet to import these files. + + import: | + **Import Files to Current Sheet** + **Usage**: + jv import - Import files from import area + jv import - Import files from reference sheet + + **Example**: + jv import Player_Import - From import area defined name + jv import ref@Data/Player.csv - From reference sheet path + + Import operation copies files from other sheets or import areas to the current workspace. + + direct: | + **Direct to Specified Upstream Vault and Stain This Workspace** + **Usage**: jv direct + + **Example**: jv direct your_vault.org + This operation connects the current workspace to the specified upstream vault and adds a stain identifier to the workspace. + + After staining, the workspace will only be able to interact with vaults of the specified identifier, ensuring data consistency. + + unstain: | + **Unstain This Workspace** + **Usage**: jv unstain + + **DANGER ZONE**: This operation removes the workspace's stain identifier, after which the workspace will be disconnected from the upstream vault. + + After unstaining, the workspace will no longer be associated with any specific vault and can be reconnected to other vaults. + However, please note that this may cause data synchronization issues, use with caution. + + update: | + **Download Latest Information from Upstream Vault** + **Usage**: jv update + + This operation synchronizes the latest file status, sheet information, and member information from the upstream vault. + + It is recommended to perform an update operation before starting work to ensure you have the latest working environment. + + docs: | + **Query Built-in Documentation** + **Usage**: + jv docs list - List all available documentation + jv docs - View content of specified documentation + jv docs -e - Return temporary path of specific documentation for editor opening + + **Example**: + jv docs get-started + jv docs collaboration -e | nano + + Built-in documentation includes JustEnoughVCS usage guides, collaboration paradigms, and best practices. diff --git a/locales/help_docs/zh-CN.yml b/locales/help_docs/zh-CN.yml index 792d9c8..2025cbe 100644 --- a/locales/help_docs/zh-CN.yml +++ b/locales/help_docs/zh-CN.yml @@ -18,11 +18,11 @@ jvv: **服务**: jvv service listen - 在当前库中运行服务端 - 另外,你可以使用 jvv <命令名称> --help 来查询更详细的帮助! + 另外,您可以使用 jvv <命令名称> --help 来查询更详细的帮助! here: | **显示此处库的信息** - **例如**:cd ./你需要查询的库/ && jvv here + **例如**:cd ./您需要查询的库/ && jvv here create: | **在给定的目录名称中创建库** @@ -55,7 +55,7 @@ jvv: **服务设置相关** **用法**: jvv service listen - 在当前库中启动服务器,以接受客户端连接 - 你可以使用 --no-log 来禁用日志输出 + 您可以使用 --no-log 来禁用日志输出 fail: jvcs: JustEnoughVCS 错误:%{err} @@ -97,7 +97,7 @@ jvv: here: info: | 找到库 *`%{name}`*!(%{num_mem} 成员,%{num_pk} 位已注册公钥) - 其中,管理着 %{num_sheets} 张表,%{num_vf} 个虚拟文件,总共 %{total_size_gb} GB + 其中,管理着 %{num_sheets} 张表,%{num_vf} 个虚拟文件,总共 %{total_size} **提示**:若要启动服务端,请运行 jvv service listen @@ -119,3 +119,222 @@ jvv: service: listen: 正在库 `%{path}` 监听来自客户端的连接 ... + +jv: + help: | + **JustEnoughVCS 本地工作区命令** + 该程序将连接至上游库,用以同步、提交本地工作区文件的变化,以供协同创作。 + + **常用别名**: + jv u 下载最新信息,jv t 追踪文件,jv mv -a 自动移动文件,jv in/out 导入或导出文件 + + **创建工作区**: + jv create <名称> - 在给定名称的目录创建工作区 + jv init - 在当前目录创建工作区 + + **指向上游库**: + jv direct <上游地址> - 将您的工作区指向该库 + 指定上游库后,您的工作区将被 *染色*,此后,您将无法连接至不同标识的库 + + jv unstain - 将您的工作区祛色(移除染色标识),此后该工作区将与上游库无关 + + **账户管理**: + jv account list - 列出该计算机所有的账户,以及是否注册私钥 + jv account as <账户名称> - 切换当前账户 + jv account add <账户名称> - 为当前计算机添加账户 + jv account remove <账户名称> - 删除该账户 + jv account mvkey <账户名称> <私钥文件> - 移动私钥到指定账户 + + **信息同步**: + jv update - 从上游工作区下载最新的信息 + + **表操作**: + jv sheet list - 列出上游工作区的所有表 + jv sheet use <表名称> - 使用指定的表开始当前工作(不存在则自动创建) + jv sheet exit - 退出当前工作 + + jv import <文件包名称> - 从导入区导入文件 + jv import <参照表中目录> - 从参照表导入文件 + jv export <文件> <表名称> -m <描述> -n <文件包名称> - 导出指定的文件包到其他表的导入区 + + **文件操作** + jv move <文件> <到> - 安全地重命名文件 + jv move auto - 自动处理本地文件的移动或重命名 + jv track <文件> - 追踪、上传文件到上游库 + + **查询内建文档** + jv docs list - 列出所有可用的文档 + jv docs <文档名称> - 查看指定文档的内容 + 或 jv docs <文档名称> -e - 返回特定文档的临时路径以供编辑器打开 + **例如**:jv docs get-started -e | nano + + 您可以使用 jv <命令名称> --help 来查询更详细的帮助! + + **提示**:若您需要了解 JustEnoughVCS 的协作范式,请使用 jv docs get-started + + account: | + **管理本地账户** + **用法**: + jv account list - 列出该计算机所有的账户,以及是否注册私钥 + jv account as <账户名称> - 切换当前账户 + jv account add <账户名称> - 为当前计算机添加账户 + jv account remove <账户名称> - 删除该账户 + jv account mvkey <账户名称> <私钥文件> - 移动私钥到指定账户 + + 账户是本地计算机上的身份标识,每个账户可以关联不同的私钥。 + 您需要先设置账户才能与上游库进行交互。 + + + sheet: | + **管理文件表** + **用法**: + jv sheet list - 列出上游工作区的所有表 + jv sheet use <表名称> - 使用指定的表开始当前工作(不存在则自动创建) + jv sheet exit - 退出当前工作 + + 表是 JustEnoughVCS 中的核心概念,每个表代表一个独立的文件集合。 + 您可以在不同的表之间切换工作,或者将文件从一个表导出到另一个表。 + + + create: | + **创建指定名称的工作区** + **用法**:jv create <工作区名称> + + **例如**:jv create my_workspace + 上述操作会在当前目录创建名为 my_workspace 的目录,并在其中初始化工作区。 + + 工作区是您本地的工作环境,用于与上游库进行文件同步和版本控制。 + + + init: | + **在此目录创建工作区** + **用法**:jv init + + 该命令会在当前所在的目录创建工作区,工作区名称由当前所在目录名称决定。 + + 如果当前目录不为空,该操作将会失败。请确保在空目录中执行此命令。 + + + here: | + **查询此处目录信息** + **用法**:jv here + + 显示当前目录文件的详细信息,包括: + - 文件名称、大小、版本号 + - 文件当前的持有人 + - 文件最新版本的提交信息 + + 这是了解当前工作区目录状态的快速方式。 + + + track: | + **追踪本地的文件** + **用法**:jv track <文件路径> + + **例如**:jv track src/main.rs + 第一次追踪文件时,会创建并上传 “第一版本”,然后自动持有该文件的编辑权。 + 后续追踪同一文件时,会更新文件的新版本。 + + 追踪文件是版本控制的基础操作,确保您的更改能够同步到上游库。 + + + hold: | + **拿取文件:从上游库获得该文件的编辑权** + **用法**:jv hold <文件路径> + + **例如**:jv hold src/lib.rs + 当您需要编辑某个文件时,必须先持有该文件的编辑权。 + 持有文件后,其他协作者将无法同时编辑该文件,避免冲突。 + + 编辑完成后,请记得追踪文件以保存更改。 + + + throw: | + **丢弃文件:从上游库放弃该文件的编辑权** + **用法**:jv throw <文件路径> + + **例如**:jv throw src/config.rs + 当您不再需要编辑某个文件时,可以丢弃该文件的编辑权。 + 丢弃后,其他协作者就可以持有并编辑该文件。 + + 如果您对文件进行了更改但尚未追踪,丢弃操作会丢失这些更改。 + + + move: | + **移动本地文件** + **用法**: + jv move <源文件> <目标位置> - 安全地重命名或移动文件 + jv move auto - 自动处理本地文件的移动或重命名 + + **例如**: + jv move old_name.txt new_name.txt + jv move src/old_dir/file.rs src/new_dir/file.rs + jv move auto + + 安全移动操作会保持文件的版本历史,而自动移动会检测并处理所有重命名。 + + + export: | + **将文件导出至其他表的待导入区** + **用法**:jv export <文件> <目标表> -m <描述> -n <文件包名称> + + **例如**:jv export data.csv analytics -m "导出分析数据" -n "analysis_data" + 该操作会将指定的文件打包并发送到目标表的导入区。 + + 其他协作者可以在目标表中使用 jv import 命令来导入这些文件。 + + + import: | + **导入文件到当前表** + **用法**: + jv import <文件包名称> - 从导入区导入文件 + jv import <参照表中目录> - 从参照表导入文件 + + **例如**: + jv import Player_Import - 来自导入区定义的名称 + jv import ref@Data/Player.csv - 来自参照表的路径 + + 导入操作会将文件从其他表或导入区复制到当前工作区。 + + + direct: | + **定向到指定上游库,并染色该工作区** + **用法**:jv direct <上游库地址> + + **例如**:jv direct your_vault.org + 该操作会将当前工作区连接到指定的上游库,并为工作区添加染色标识。 + + 染色后,该工作区将只能与指定标识的库进行交互,确保数据一致性。 + + + unstain: | + **为工作区祛色** + **用法**:jv unstain + + **危险操作**:该操作会移除工作区的染色标识,此后该工作区将与上游库断开连接。 + + 祛色后,工作区将不再与任何特定库关联,可以重新连接到其他库。 + 但请注意,这可能会导致数据同步问题,请谨慎使用。 + + + update: | + **从上游库下载最新的信息** + **用法**:jv update + + 该操作会从上游库同步最新的文件状态、表信息和成员信息。 + + 建议在开始工作前先执行更新操作,确保您拥有最新的工作环境。 + + + docs: | + **查询内建文档** + **用法**: + jv docs list - 列出所有可用的文档 + jv docs <文档名称> - 查看指定文档的内容 + jv docs <文档名称> -e - 返回特定文档的临时路径以供编辑器打开 + + **例如**: + jv docs get-started + jv docs collaboration -e | nano + + 内建文档包含 JustEnoughVCS 的使用指南、协作范式和最佳实践。 -- cgit From 30c0ced402b676c64b0c3d82d8eef34c0c2bbb28 Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Tue, 21 Oct 2025 21:49:37 +0800 Subject: Completed jv bin --- src/bin/jv.rs | 274 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++- src/bin/jvv.rs | 44 +++++---- 2 files changed, 299 insertions(+), 19 deletions(-) diff --git a/src/bin/jv.rs b/src/bin/jv.rs index a8b0a1f..9530203 100644 --- a/src/bin/jv.rs +++ b/src/bin/jv.rs @@ -1,7 +1,279 @@ +use clap::{Parser, Subcommand, arg, command}; +use just_enough_vcs_cli::utils::{lang_selector::current_locales, md_colored::md}; +use rust_i18n::{set_locale, t}; + // Import i18n files rust_i18n::i18n!("locales", fallback = "en"); +#[derive(Parser, Debug)] +#[command( + disable_help_flag = true, + disable_version_flag = true, + disable_help_subcommand = true, + help_template = "{all-args}" +)] + +struct JustEnoughVcsWorkspace { + #[command(subcommand)] + command: JustEnoughVcsWorkspaceCommand, +} + +#[derive(Subcommand, Debug)] +enum JustEnoughVcsWorkspaceCommand { + // Member management + /// Manage your local accounts + #[command(subcommand)] + Account(AccountManage), + + /// Create an empty workspace + Create(CreateWorkspaceArgs), + + /// Create an empty workspace in the current directory + Init(InitWorkspaceArgs), + + /// Get workspace information in the current directory + #[command(alias = "h")] + Here(HereArgs), + + // Sheet management + /// Manage sheets in the workspace + #[command(subcommand)] + Sheet(SheetManage), + + // File management + /// Track files to the upstream vault + /// First track - Create and upload the "First Version", then hold them + /// Subsequent tracks - Update files with new versions + #[command(alias = "t")] + Track(TrackFileArgs), + + /// Hold files for editing + #[command(alias = "hd")] + Hold(HoldFileArgs), + + /// Throw files, and release edit rights + #[command(alias = "tr")] + Throw(ThrowFileArgs), + + /// Move or rename files safely + #[command(alias = "mv")] + Move(MoveFileArgs), + + /// Export files to other worksheet + #[command(alias = "out")] + Export(ExportFileArgs), + + /// Import files from reference sheet or import area + #[command(alias = "in")] + Import(ImportFileArgs), + + // Connection management + /// Direct to an upstream vault and stain this workspace + Direct(DirectArgs), + + /// DANGER ZONE : Unstain this workspace + Unstain(UnstainArgs), + + // Other + /// Query built-in documentation + Docs(DocsArgs), +} + +#[derive(Subcommand, Debug)] +enum AccountManage { + /// Show help information + #[command(alias = "--help", alias = "-h")] + Help, +} + +#[derive(Subcommand, Debug)] +enum SheetManage { + /// Show help information + #[command(alias = "--help", alias = "-h")] + Help, +} + +#[derive(Parser, Debug)] +struct CreateWorkspaceArgs { + /// Show help information + #[arg(short, long)] + help: bool, +} + +#[derive(Parser, Debug)] +struct InitWorkspaceArgs { + /// Show help information + #[arg(short, long)] + help: bool, +} + +#[derive(Parser, Debug)] +struct HereArgs { + /// Show help information + #[arg(short, long)] + help: bool, +} + +#[derive(Parser, Debug)] +struct TrackFileArgs { + /// Show help information + #[arg(short, long)] + help: bool, +} + +#[derive(Parser, Debug)] +struct HoldFileArgs { + /// Show help information + #[arg(short, long)] + help: bool, +} + +#[derive(Parser, Debug)] +struct ThrowFileArgs { + /// Show help information + #[arg(short, long)] + help: bool, +} + +#[derive(Parser, Debug)] +struct MoveFileArgs { + /// Show help information + #[arg(short, long)] + help: bool, +} + +#[derive(Parser, Debug)] +struct ExportFileArgs { + /// Show help information + #[arg(short, long)] + help: bool, +} + +#[derive(Parser, Debug)] +struct ImportFileArgs { + /// Show help information + #[arg(short, long)] + help: bool, +} + +#[derive(Parser, Debug)] +struct DirectArgs { + /// Show help information + #[arg(short, long)] + help: bool, +} + +#[derive(Parser, Debug)] +struct UnstainArgs { + /// Show help information + #[arg(short, long)] + help: bool, +} + +#[derive(Parser, Debug)] +struct DocsArgs { + /// Show help information + #[arg(short, long)] + help: bool, +} + #[tokio::main] async fn main() { - println!("Hello, World!") + // Init i18n + set_locale(¤t_locales()); + + // Init colored + #[cfg(windows)] + colored::control::set_virtual_terminal(true).unwrap(); + + let Ok(parser) = JustEnoughVcsWorkspace::try_parse() else { + println!("{}", md(t!("jv.help"))); + return; + }; + + match parser.command { + JustEnoughVcsWorkspaceCommand::Account(account_manage) => match account_manage { + AccountManage::Help => { + println!("{}", md(t!("jv.account"))); + } + }, + JustEnoughVcsWorkspaceCommand::Create(create_workspace_args) => { + if create_workspace_args.help { + println!("{}", md(t!("jv.create"))); + return; + } + } + JustEnoughVcsWorkspaceCommand::Init(init_workspace_args) => { + if init_workspace_args.help { + println!("{}", md(t!("jv.init"))); + return; + } + } + JustEnoughVcsWorkspaceCommand::Here(here_args) => { + if here_args.help { + println!("{}", md(t!("jv.here"))); + return; + } + } + JustEnoughVcsWorkspaceCommand::Sheet(sheet_manage) => match sheet_manage { + SheetManage::Help => { + println!("{}", md(t!("jv.sheet"))); + return; + } + }, + JustEnoughVcsWorkspaceCommand::Track(track_file_args) => { + if track_file_args.help { + println!("{}", md(t!("jv.track"))); + return; + } + } + JustEnoughVcsWorkspaceCommand::Hold(hold_file_args) => { + if hold_file_args.help { + println!("{}", md(t!("jv.hold"))); + return; + } + } + JustEnoughVcsWorkspaceCommand::Throw(throw_file_args) => { + if throw_file_args.help { + println!("{}", md(t!("jv.throw"))); + return; + } + } + JustEnoughVcsWorkspaceCommand::Move(move_file_args) => { + if move_file_args.help { + println!("{}", md(t!("jv.move"))); + return; + } + } + JustEnoughVcsWorkspaceCommand::Export(export_file_args) => { + if export_file_args.help { + println!("{}", md(t!("jv.export"))); + return; + } + } + JustEnoughVcsWorkspaceCommand::Import(import_file_args) => { + if import_file_args.help { + println!("{}", md(t!("jv.import"))); + return; + } + } + JustEnoughVcsWorkspaceCommand::Direct(direct_args) => { + if direct_args.help { + println!("{}", md(t!("jv.direct"))); + return; + } + } + JustEnoughVcsWorkspaceCommand::Unstain(unstain_args) => { + if unstain_args.help { + println!("{}", md(t!("jv.unstain"))); + return; + } + } + JustEnoughVcsWorkspaceCommand::Docs(docs_args) => { + if docs_args.help { + println!("{}", md(t!("jv.docs"))); + return; + } + } + } } diff --git a/src/bin/jvv.rs b/src/bin/jvv.rs index 1dd2275..50dc3b3 100644 --- a/src/bin/jvv.rs +++ b/src/bin/jvv.rs @@ -8,7 +8,7 @@ use just_enough_vcs::{ }, vcs::{ connection::action_service::server_entry, - constants::{SERVER_FILE_VAULT, SERVER_FILE_VF_META}, + constants::SERVER_FILE_VAULT, current::current_vault_path, data::{ member::Member, @@ -35,11 +35,11 @@ rust_i18n::i18n!("locales/help_docs", fallback = "en"); )] struct JustEnoughVcsVault { #[command(subcommand)] - command: JustEnoughVcsCommand, + command: JustEnoughVcsVaultCommand, } #[derive(Subcommand, Debug)] -enum JustEnoughVcsCommand { +enum JustEnoughVcsVaultCommand { /// Get vault info in the current directory Here(HereArgs), @@ -161,28 +161,28 @@ async fn main() { }; match parser.command { - JustEnoughVcsCommand::Here(here_args) => { + JustEnoughVcsVaultCommand::Here(here_args) => { if here_args.help { println!("{}", md(t!("jvv.here"))); return; } jvv_here(here_args).await; } - JustEnoughVcsCommand::Create(create_vault_args) => { + JustEnoughVcsVaultCommand::Create(create_vault_args) => { if create_vault_args.help { println!("{}", md(t!("jvv.create"))); return; } jvv_create(create_vault_args).await; } - JustEnoughVcsCommand::Init(init_vault_args) => { + JustEnoughVcsVaultCommand::Init(init_vault_args) => { if init_vault_args.help { println!("{}", md(t!("jvv.init"))); return; } jvv_init(init_vault_args).await; } - JustEnoughVcsCommand::Member(member_manage) => { + JustEnoughVcsVaultCommand::Member(member_manage) => { let vault_cfg = VaultConfig::read() .await .unwrap_or_else(|_| panic!("{}", t!("jvv.fail.no_vault_here").trim().to_string())); @@ -226,7 +226,7 @@ async fn main() { } } } - JustEnoughVcsCommand::Service(service_manage) => match service_manage { + JustEnoughVcsVaultCommand::Service(service_manage) => match service_manage { ServiceManage::Listen(listen_args) => { if listen_args.help { println!("{}", md(t!("jvv.service"))); @@ -284,14 +284,8 @@ async fn jvv_here(_args: HereArgs) { while let Ok(Some(entry)) = entries.next_entry().await { if let Ok(metadata) = entry.metadata().await { if metadata.is_file() { - if entry - .file_name() - .to_string_lossy() - .ends_with(SERVER_FILE_VF_META) - { - num_vf += 1; - total_size += metadata.len(); - } + num_vf += 1; + total_size += metadata.len(); } } } @@ -332,6 +326,21 @@ async fn jvv_here(_args: HereArgs) { }; let num_ref_sheet_managed_files = ref_sheet.mapping().len(); + let total_size_str = if total_size < 1024 { + format!("{} B", total_size) + } else if total_size < 1024 * 1024 { + format!("{:.2} KB", total_size as f64 / 1024.0) + } else if total_size < 1024 * 1024 * 1024 { + format!("{:.2} MB", total_size as f64 / (1024.0 * 1024.0)) + } else if total_size < 1024 * 1024 * 1024 * 1024 { + format!("{:.2} GB", total_size as f64 / (1024.0 * 1024.0 * 1024.0)) + } else { + format!( + "{:.2} TB", + total_size as f64 / (1024.0 * 1024.0 * 1024.0 * 1024.0) + ) + }; + // Success println!( "{}", @@ -340,11 +349,10 @@ async fn jvv_here(_args: HereArgs) { name = vault_name, num_sheets = num_sheets, num_vf = num_vf, - total_size = total_size, num_mem = num_mem, num_pk = num_pk, num_ref_sheet_managed_files = num_ref_sheet_managed_files, - total_size_gb = (total_size as f64) / (1024.0 * 1024.0 * 1024.0) + total_size = total_size_str )) ) } -- cgit