More rust. I have no idea what I'm doing and I am beginning to think golang is better.

This commit is contained in:
Anna Rose Wiggins 2025-08-06 15:00:50 -04:00
parent af21756cef
commit 08aac599a6
4 changed files with 318 additions and 1 deletions

29
src/bin/evinfo.rs Normal file
View file

@ -0,0 +1,29 @@
use std::io;
use clap::Parser;
use evdev::Device;
#[derive(Parser, Debug)]
#[command(version, about, long_about = None)]
struct Args {
#[arg(short, long)]
verbose: bool,
}
fn main() {
let args = Args::parse();
let mut _verbosity = 0;
if args.verbose {
_verbosity += 1;
}
let devices = get_devices();
for _device in devices.iter() {
// print_device(device);
}
}
fn get_devices() -> Vec<evdev::Device> {
return Vec::new();
}

View file

@ -1,26 +1,40 @@
use std::env;
use std::error;
use std::fs;
use clap::Parser;
use shellexpand;
type Result<T> = std::result::Result<T, Box<dyn error::Error>>;
#[derive(Parser, Debug)]
#[command(version, about, long_about = None)]
#[command(version, about, long_about)]
struct Args {
/// The directory that contains your YAML configuration.
#[arg(short, long, default_value = "~/.config/joyful/")]
config: String,
/// Print extra information to the console.
#[arg(short, long)]
debug: bool,
/// Volume for text-to-speech. (0-200)
#[arg(long, default_value_t = 100)]
tts_volume: u8,
/// Median pitch for text-to-speech. (0-100)
#[arg(long, default_value_t = 50)]
tts_pitch: u8,
/// Pitch range for text-to-speech. (0-100)
#[arg(long, default_value_t = 50)]
tts_range: u8,
/// Speaking speed for text-to-speech in words per minute.
#[arg(long, default_value_t = 175)]
tts_speed: u8,
/// The espeak-ng voice to use for text-to-speech.
#[arg(long, default_value = "en")]
tts_voice: String,
}
@ -30,6 +44,7 @@ fn main() {
let args = Args::parse();
// Parse configs
let config_files = get_config_files(args.config);
// Initialize TTS
@ -44,6 +59,39 @@ fn main() {
// Loop: Parse Input
}
fn get_config_files(config_dir: String) -> Result<Vec<String>> {
let config_dir = shellexpand::full(&config_dir)?;
let paths = fs::read_dir(config_dir)?;
let mut files: Vec<String> = Vec::new();
for path in paths {
let path = match path {
Ok(path) => {
// DEBUG
println!("{:?}", path.path());
path.path()
}
Err(err) => {
println!("{err}");
continue;
}
};
if path.ends_with("yml") || path.ends_with("yaml") {
let path = match path.to_str() {
Some(path) => path,
None => {
continue;
}
};
files.push(path.to_string());
}
}
return files;
}
// package main
// import (