Extract support code from executable filename
Agent now reads its own filename to extract the 6-digit code. User just downloads GuruConnect-123456.exe and double-clicks - no command line arguments or prompts needed. Supports patterns: - GuruConnect-123456.exe - GuruConnect_123456.exe - GuruConnect123456.exe 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -23,6 +23,33 @@ use anyhow::Result;
|
|||||||
use tracing::{info, error, Level};
|
use tracing::{info, error, Level};
|
||||||
use tracing_subscriber::FmtSubscriber;
|
use tracing_subscriber::FmtSubscriber;
|
||||||
|
|
||||||
|
/// Extract a 6-digit support code from the executable's filename.
|
||||||
|
/// Looks for patterns like "GuruConnect-123456.exe" or "123456.exe"
|
||||||
|
fn extract_code_from_filename() -> Option<String> {
|
||||||
|
// Get the path to the current executable
|
||||||
|
let exe_path = std::env::current_exe().ok()?;
|
||||||
|
let filename = exe_path.file_stem()?.to_str()?;
|
||||||
|
|
||||||
|
// Look for a 6-digit number in the filename
|
||||||
|
// Try common patterns: "Name-123456", "Name_123456", "123456"
|
||||||
|
for part in filename.split(|c| c == '-' || c == '_' || c == '.') {
|
||||||
|
let trimmed = part.trim();
|
||||||
|
if trimmed.len() == 6 && trimmed.chars().all(|c| c.is_ascii_digit()) {
|
||||||
|
return Some(trimmed.to_string());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Also check if the last 6 characters are digits (e.g., "GuruConnect123456")
|
||||||
|
if filename.len() >= 6 {
|
||||||
|
let last_six = &filename[filename.len() - 6..];
|
||||||
|
if last_six.chars().all(|c| c.is_ascii_digit()) {
|
||||||
|
return Some(last_six.to_string());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
None
|
||||||
|
}
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> Result<()> {
|
async fn main() -> Result<()> {
|
||||||
// Initialize logging
|
// Initialize logging
|
||||||
@@ -34,21 +61,12 @@ async fn main() -> Result<()> {
|
|||||||
|
|
||||||
info!("GuruConnect Agent v{}", env!("CARGO_PKG_VERSION"));
|
info!("GuruConnect Agent v{}", env!("CARGO_PKG_VERSION"));
|
||||||
|
|
||||||
// Parse command line arguments
|
// Extract support code from executable filename
|
||||||
let args: Vec<String> = std::env::args().collect();
|
// e.g., GuruConnect-123456.exe -> 123456
|
||||||
let support_code = if args.len() > 1 {
|
let support_code = extract_code_from_filename();
|
||||||
let code = args[1].trim().to_string();
|
if let Some(ref code) = support_code {
|
||||||
// Validate it looks like a 6-digit code
|
info!("Support code from filename: {}", code);
|
||||||
if code.len() == 6 && code.chars().all(|c| c.is_ascii_digit()) {
|
|
||||||
info!("Support code provided: {}", code);
|
|
||||||
Some(code)
|
|
||||||
} else {
|
|
||||||
info!("Invalid support code format, ignoring: {}", code);
|
|
||||||
None
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
None
|
|
||||||
};
|
|
||||||
|
|
||||||
// Load configuration
|
// Load configuration
|
||||||
let mut config = config::Config::load()?;
|
let mut config = config::Config::load()?;
|
||||||
|
|||||||
Reference in New Issue
Block a user