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
2 changes: 1 addition & 1 deletion src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use std::path::PathBuf;
version,
before_help = "",
about = "Backend.AI SSH - Parallel command execution across cluster nodes",
long_about = "bssh is a high-performance parallel SSH command execution tool for cluster management, built with Rust.\nIt enables efficient execution of commands across multiple nodes simultaneously with real-time output streaming.\nThe tool provides secure file transfer capabilities using SFTP protocol and supports multiple authentication\nmethods including SSH keys (with passphrase support), SSH agent, and password authentication.\nIt automatically detects Backend.AI multi-node session environments.",
long_about = "bssh is a high-performance parallel SSH command execution tool for cluster management.\nIt enables efficient execution of commands across multiple nodes simultaneously with real-time output streaming.\nThe tool provides secure file transfer capabilities using SFTP protocol and supports multiple authentication\nmethods including SSH keys (with passphrase support), SSH agent, and password authentication.\nIt automatically detects Backend.AI multi-node session environments.",
after_help = "EXAMPLES:\n Execute command on hosts: bssh -H \"user@host1,host2\" \"uptime\"\n Use cluster configuration: bssh -c production \"df -h\"\n Upload files with glob: bssh -c staging upload \"*.log\" /tmp/\n Download from all nodes: bssh -c web download /var/log/app.log ./logs/\n Interactive mode (multiplex): bssh -c production interactive\n Test connectivity: bssh -c staging ping\n\nDeveloped and maintained as part of the Backend.AI project.\nFor more examples and documentation, visit: https://github.com/lablup/bssh"
)]
pub struct Cli {
Expand Down
18 changes: 16 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// limitations under the License.

use anyhow::Result;
use clap::Parser;
use clap::{CommandFactory, Parser};
use std::path::{Path, PathBuf};
use std::time::Duration;

Expand All @@ -33,6 +33,13 @@ use bssh::{
utils::init_logging,
};

/// Show help message and exit
fn show_help() {
let mut cmd = Cli::command();
let _ = cmd.print_help();
eprintln!(); // Add a newline after help
}

/// Format a Duration into a human-readable string
fn format_duration(duration: Duration) -> String {
let total_seconds = duration.as_secs_f64();
Expand Down Expand Up @@ -61,13 +68,20 @@ fn format_duration(duration: Duration) -> String {

#[tokio::main]
async fn main() -> Result<()> {
// Check if no arguments were provided
let args: Vec<String> = std::env::args().collect();
if args.len() == 1 {
// Show help when no arguments provided
show_help();
std::process::exit(0);
}

let cli = Cli::parse();

// Initialize logging
init_logging(cli.verbose);

// Check if user explicitly specified options
let args: Vec<String> = std::env::args().collect();
let has_explicit_config = args.iter().any(|arg| arg == "--config");
let has_explicit_parallel = args.iter().any(|arg| {
arg == "-p"
Expand Down