Last active
November 5, 2025 14:24
-
-
Save su8/9733dbd3a39e7ca634470de0067ffb3f to your computer and use it in GitHub Desktop.
main2.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use std::env; | |
| use std::process; | |
| fn variants(word: &str) -> Vec<String> { | |
| let mut result = Vec::new(); | |
| result.push(word.to_string()); | |
| if !word.is_empty() { | |
| let mut capitalized = word.to_string(); | |
| if let Some(first_char) = capitalized.get_mut(0..1) { first_char.make_ascii_uppercase(); } | |
| result.push(capitalized); | |
| } | |
| result.push(word.to_uppercase()); | |
| result | |
| } | |
| fn main() { | |
| let args: Vec<String> = env::args().collect(); | |
| if args.len() < 6 { process::exit(0); } | |
| let mut usernames = vec!["frost".to_string()]; | |
| let mut roles = vec!["user".to_string(), "root".to_string()]; | |
| let separators = vec!["".to_string(), "_".to_string()]; | |
| if args[1].starts_with('-') && args[1].contains('f') { usernames = vec![args[2].clone()]; } | |
| if args[3].starts_with('-') && args[3].contains('o') { roles = vec![args[4].clone(), args[5].clone()]; } | |
| for username in &usernames { | |
| for role in &roles { | |
| for sep in &separators { | |
| for user in variants(username) { | |
| for r in variants(role) { | |
| println!("{}{}{}", user, sep, r); | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment