Skip to content
This repository was archived by the owner on Feb 19, 2026. It is now read-only.

Commit 7195c6c

Browse files
committed
add: BmsEventCommands
1 parent 144abee commit 7195c6c

File tree

4 files changed

+60
-5
lines changed

4 files changed

+60
-5
lines changed

cli/src/bms.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
pub mod bms_event;
21
pub mod work;
32

43
use std::{cell::LazyCell, collections::HashMap, fs::FileType, path::Path};

cli/src/lib.rs

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,22 @@ pub mod fs;
33
pub mod media;
44
pub mod options;
55

6+
use std::path::PathBuf;
7+
68
use clap::{Parser, Subcommand};
79
use log::info;
8-
use std::path::PathBuf;
910

10-
use crate::fs::moving::ReplacePreset;
1111
use crate::{
1212
bms::{
1313
get_dir_bms_info, get_dir_bms_list, is_root_dir, is_work_dir, parse_bms_file,
1414
parse_bmson_file,
1515
},
16-
fs::{bms_dir_similarity, is_dir_having_file, is_file_same_content, remove_empty_folders},
16+
fs::{
17+
bms_dir_similarity, is_dir_having_file, is_file_same_content, moving::ReplacePreset,
18+
remove_empty_folders,
19+
},
1720
options::{
21+
bms_event::BMSEvent,
1822
pack::{
1923
pack_hq_to_lq, pack_raw_to_hq, pack_setup_rawpack_to_hq, pack_update_rawpack_to_hq,
2024
},
@@ -91,6 +95,11 @@ pub enum Commands {
9195
#[command(subcommand)]
9296
command: RawpackCommands,
9397
},
98+
/// BMS event related operations
99+
BmsEvent {
100+
#[command(subcommand)]
101+
command: BmsEventCommands,
102+
},
94103
}
95104

96105
#[derive(Subcommand)]
@@ -470,6 +479,25 @@ pub enum RootCommands {
470479
},
471480
}
472481

482+
#[derive(Subcommand)]
483+
pub enum BmsEventCommands {
484+
/// Open BMS event list page
485+
OpenList {
486+
/// BMS event type
487+
#[arg(value_name = "Event type")]
488+
event: BMSEvent,
489+
},
490+
/// Open multiple BMS event work details pages
491+
OpenWorks {
492+
/// BMS event type
493+
#[arg(value_name = "Event type")]
494+
event: BMSEvent,
495+
/// Work IDs (space or comma separated)
496+
#[arg(value_name = "Work IDs")]
497+
work_ids: Vec<u32>,
498+
},
499+
}
500+
473501
#[derive(Subcommand)]
474502
pub enum PackCommands {
475503
/// Raw pack -> HQ pack
@@ -820,6 +848,16 @@ pub async fn run_command(command: &Commands) -> Result<(), Box<dyn std::error::E
820848
info!("Setting completed");
821849
}
822850
},
851+
Commands::BmsEvent { command } => match command {
852+
BmsEventCommands::OpenList { event } => {
853+
crate::options::bms_event::open_event_list(*event).await?;
854+
info!("List opened");
855+
}
856+
BmsEventCommands::OpenWorks { event, work_ids } => {
857+
crate::options::bms_event::open_event_works(*event, work_ids).await?;
858+
info!("All work pages opened");
859+
}
860+
},
823861
}
824862

825863
Ok(())

cli/src/options.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
pub mod bms_event;
12
pub mod pack;
23
pub mod rawpack;
34
pub mod root;
Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::str::FromStr;
44

55
use smol::process::Command;
66

7-
#[derive(Debug, Clone, Copy)]
7+
#[derive(Debug, Clone, Copy, clap::ValueEnum)]
88
#[repr(u32)]
99
pub enum BMSEvent {
1010
BOFTT = 20,
@@ -79,6 +79,7 @@ pub async fn open_browser(url: &str) -> io::Result<()> {
7979
Ok(())
8080
}
8181

82+
/// Interactive BMS event browser (legacy function)
8283
pub async fn activate() {
8384
log::info!("Select BMS Event:");
8485
for event in [BMSEvent::BOFTT, BMSEvent::LetsBMSEdit3] {
@@ -149,3 +150,19 @@ pub async fn activate() {
149150
}
150151
}
151152
}
153+
154+
/// Open BMS event list page
155+
pub async fn open_event_list(event: BMSEvent) -> io::Result<()> {
156+
log::info!("Opening BMS event list: {}", event);
157+
open_browser(event.list_url()).await
158+
}
159+
160+
/// Open multiple BMS event work details pages
161+
pub async fn open_event_works(event: BMSEvent, work_ids: &[u32]) -> io::Result<()> {
162+
log::info!("Opening BMS event works: {} (IDs: {:?})", event, work_ids);
163+
for &work_id in work_ids {
164+
let url = event.work_info_url(work_id);
165+
open_browser(&url).await?;
166+
}
167+
Ok(())
168+
}

0 commit comments

Comments
 (0)