Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Rename Rust CLI binary to ente-rs

Manav Rathic993e24df283
diff --git a/rust/README.md b/rust/README.md
index 702928303b..50e615d7c5 100644
--- a/rust/README.md
+++ b/rust/README.md
@@ -10,7 +10,7 @@ cargo clippy # Lint
cargo build # Build
cargo test # Test
-cargo run --bin ente-cli -- --help # Run the Ente Rust CLI
+cargo run --bin ente-rs -- --help # Run the Ente Rust CLI
```
CI runs with `RUSTFLAGS="-D warnings"` so warnings will cause checks to fail.
diff --git a/rust/apps/cli/Cargo.toml b/rust/apps/cli/Cargo.toml
index 1d7b299f47..a75a2e6a77 100644
--- a/rust/apps/cli/Cargo.toml
+++ b/rust/apps/cli/Cargo.toml
@@ -7,10 +7,6 @@ homepage = "https://ente.com"
repository = "https://github.com/ente-io/ente"
license = "AGPL-3.0-only"
-[[bin]]
-name = "ente-cli"
-path = "src/main.rs"
-
[dependencies]
# CLI
clap = { version = "4.5", features = ["derive", "env"] }
diff --git a/rust/apps/cli/README.md b/rust/apps/cli/README.md
index 69da9729aa..4b53293ec6 100644
--- a/rust/apps/cli/README.md
+++ b/rust/apps/cli/README.md
@@ -3,5 +3,5 @@ WIP Ente Rust CLI.
## Development
```sh
-cargo run --bin ente-cli -- --help
+cargo run --bin ente-rs -- --help
```
diff --git a/rust/apps/cli/src/api/auth.rs b/rust/apps/cli/src/api/auth.rs
index 4441570fff..4c75b06278 100644
--- a/rust/apps/cli/src/api/auth.rs
+++ b/rust/apps/cli/src/api/auth.rs
@@ -1,5 +1,5 @@
use crate::{
- api::{ApiClient, models::*},
+ api::{ApiClient, client::USER_AGENT, models::*},
models::error::{Error, Result},
};
use ente_accounts::{AccountsClient, AccountsClientConfig};
@@ -18,7 +18,7 @@ where
fn shared_client(api: &ApiClient, account_id: Option<&str>) -> Result<AccountsClient> {
let mut config = AccountsClientConfig::new(api.client_package())
.with_base_url(api.base_url().to_string())
- .with_user_agent(format!("ente-cli-rust/{}", env!("CARGO_PKG_VERSION")));
+ .with_user_agent(USER_AGENT);
if let Some(token) = account_id.and_then(|id| api.get_token(id)) {
config = config.with_auth_token(token);
}
diff --git a/rust/apps/cli/src/api/client.rs b/rust/apps/cli/src/api/client.rs
index dfda4839a2..22c790f2f7 100644
--- a/rust/apps/cli/src/api/client.rs
+++ b/rust/apps/cli/src/api/client.rs
@@ -13,6 +13,7 @@ use tokio::time::sleep;
const TOKEN_HEADER: &str = "X-Auth-Token";
const CLIENT_PKG_HEADER: &str = "X-Client-Package";
const DEFAULT_CLIENT_PACKAGE: &str = "io.ente.photos";
+pub(crate) const USER_AGENT: &str = concat!("ente-rs/", env!("CARGO_PKG_VERSION"));
/// Maximum number of retry attempts for failed requests
const MAX_RETRIES: u32 = 3;
@@ -83,14 +84,14 @@ impl ApiClient {
{
let client = Client::builder()
.timeout(Duration::from_secs(30))
- .user_agent(format!("ente-cli-rust/{}", env!("CARGO_PKG_VERSION")))
+ .user_agent(USER_AGENT)
.build()?;
let download_client = Client::builder()
.timeout(Duration::from_secs(300))
.pool_idle_timeout(Duration::from_secs(90))
.pool_max_idle_per_host(10)
- .user_agent(format!("ente-cli-rust/{}", env!("CARGO_PKG_VERSION")))
+ .user_agent(USER_AGENT)
.build()?;
Ok(Self {
diff --git a/rust/apps/cli/src/auth_flow.rs b/rust/apps/cli/src/auth_flow.rs
index 2ab2cc0dfe..d6e76adf8c 100644
--- a/rust/apps/cli/src/auth_flow.rs
+++ b/rust/apps/cli/src/auth_flow.rs
@@ -1,5 +1,5 @@
use crate::{
- api::{ApiClient, models::KeyAttributes},
+ api::{ApiClient, client::USER_AGENT, models::KeyAttributes},
models::{
account::{AccountSecrets, App},
error::{Error, Result},
@@ -27,7 +27,7 @@ fn shared_client(
) -> Result<shared::AccountsClient> {
let mut config = shared::AccountsClientConfig::new(app.client_package())
.with_base_url(api_client.base_url().to_string())
- .with_user_agent(format!("ente-cli-rust/{}", env!("CARGO_PKG_VERSION")));
+ .with_user_agent(USER_AGENT);
if let Some(token) = account_id.and_then(|id| api_client.get_token(id)) {
config = config.with_auth_token(token);
}
diff --git a/rust/apps/cli/src/commands/account.rs b/rust/apps/cli/src/commands/account.rs
index d40e44aea3..97f2cb4b9b 100644
--- a/rust/apps/cli/src/commands/account.rs
+++ b/rust/apps/cli/src/commands/account.rs
@@ -1,4 +1,5 @@
use crate::{
+ api::client::USER_AGENT,
cli::account::{AccountCommand, AccountSubcommands},
models::{
account::{Account, AccountSecrets as StoredAccountSecrets, App},
@@ -575,7 +576,7 @@ fn new_accounts_client(endpoint: &str, app: App) -> Result<AccountsClient> {
AccountsClient::new(
AccountsClientConfig::new(app.client_package())
.with_base_url(endpoint.to_string())
- .with_user_agent("ente-cli-rust"),
+ .with_user_agent(USER_AGENT),
)
.map_err(Error::from)
}
diff --git a/rust/apps/cli/src/commands/export.rs b/rust/apps/cli/src/commands/export.rs
index 3f5f7b38be..1c80243501 100644
--- a/rust/apps/cli/src/commands/export.rs
+++ b/rust/apps/cli/src/commands/export.rs
@@ -128,7 +128,7 @@ pub async fn run_export(account_email: Option<String>, filter: ExportFilter) ->
};
if accounts.is_empty() {
- println!("No accounts configured. Use 'ente-cli account add' first.");
+ println!("No accounts configured. Use 'ente-rs account add' first.");
return Ok(());
}
diff --git a/rust/apps/cli/src/commands/sync.rs b/rust/apps/cli/src/commands/sync.rs
index 6f0d90ec8c..deede83c17 100644
--- a/rust/apps/cli/src/commands/sync.rs
+++ b/rust/apps/cli/src/commands/sync.rs
@@ -43,7 +43,7 @@ pub async fn run_sync(
};
if accounts.is_empty() {
- println!("No accounts configured. Use 'ente-cli account add' first.");
+ println!("No accounts configured. Use 'ente-rs account add' first.");
return Ok(());
}
diff --git a/rust/apps/cli/src/main.rs b/rust/apps/cli/src/main.rs
index fd803990d7..5e3a0d9cd6 100644
--- a/rust/apps/cli/src/main.rs
+++ b/rust/apps/cli/src/main.rs
@@ -27,7 +27,7 @@ async fn run() -> Result<()> {
match cli.command {
Commands::Version => {
- println!("ente-cli version {}", ente_rs::cli::version::VERSION);
+ println!("ente-rs version {}", ente_rs::cli::version::VERSION);
}
Commands::Account(account_cmd) => {
commands::account::handle_account_command(account_cmd, &storage).await?;