Skip to content

Commit

Permalink
adjust command line options to be correct
Browse files Browse the repository at this point in the history
  • Loading branch information
Harrison Ford committed Jan 30, 2024
1 parent 23fe71b commit 21b23ae
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 29 deletions.
59 changes: 31 additions & 28 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#![allow(clippy::redundant_pub_crate)]
#![allow(clippy::items_after_statements)]
#![allow(clippy::struct_excessive_bools)]
mod message_receiver;
mod place_runner;

Expand Down Expand Up @@ -27,66 +28,68 @@ enum Cli {
#[command(author, version, about, long_about = None)]
struct RunOptions {
/// The script file to run
#[arg(short, long)]
#[arg(short, long, required(true))]
script: String,

#[arg(long)]
/// The path to a place file to run (unless using team test)
#[arg(long, required_unless_present("team_test"))]
place_file: Option<String>,

#[arg(long)]
/// The universe ID of the place file
#[arg(long, required(true))]
universe_id: Option<u64>,

#[arg(long)]
/// The place ID of the place file
#[arg(long, required(true))]
place_id: Option<u64>,

#[arg(long)]
/// The creator ID of the universe / place
#[arg(long, required_unless_present("team_test"))]
creator_id: Option<u64>,

#[arg(long)]
/// The creator type of the universe / place (usually 0 for an individual, 1 for a group)
#[arg(long, required_unless_present("team_test"), default_value("0"))]
creator_type: Option<u8>,

/// The number of client instances to launch while opening this place file. You can also run scripts on these clients.
#[arg(long, default_value("0"))]
num_clients: u8,

/// Should this program exit after the first instance disconnects / times out?
#[arg(short, long)]
oneshot: bool,

/// Use this flag if the lifecycle of Roblox Studio is managed by you. Note that you will need to restart Roblox Studio for the plugin to be installed.
#[arg(long)]
no_launch: bool,

/// Use this flag if you want to keep the Roblox Studio instance around after this program exits. This is typically used with --no_launch to do repeat testing.
#[arg(long)]
no_exit: bool,

/// Use this flag if you want to open an existing place published by a group. This is still experimental and has not been tested.
#[arg(short, long)]
team_test: bool,
}

async fn run(options: RunOptions) -> Result<i32> {
let RunOptions {
script,
universe_id,
place_id,
place_file,
oneshot,
no_launch,
team_test,
creator_id,
creator_type,
no_exit,
} = options;
let mut script = File::open(script)?;
let mut script = File::open(options.script)?;
let mut str = String::default();
script.read_to_string(&mut str)?;

let place_runner = PlaceRunner {
port: 7777,
script: str,
universe_id,
place_file,
place_id,
oneshot,
no_launch,
team_test,
creator_id,
creator_type,
no_exit,
universe_id: options.universe_id,
place_file: options.place_file,
place_id: options.place_id,
oneshot: options.oneshot,
no_launch: options.no_launch,
team_test: options.team_test,
creator_id: options.creator_id,
creator_type: options.creator_type,
no_exit: options.no_exit,
num_clients: options.num_clients,
};

let (exit_sender, exit_receiver) = async_channel::unbounded::<()>();
Expand Down
3 changes: 2 additions & 1 deletion src/place_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ pub struct PlaceRunner {
pub place_id: Option<u64>,
pub creator_id: Option<u64>,
pub creator_type: Option<u8>,
pub num_clients: u8,
pub no_launch: bool,
pub oneshot: bool,
pub team_test: bool,
Expand Down Expand Up @@ -110,7 +111,7 @@ impl PlaceRunner {
"-creatorType".to_string(),
format!("{:}", self.creator_type.unwrap()),
"-numtestserverplayersuponstartup".to_string(),
"1".to_string(),
format!("{:}", self.num_clients),
]
}
};
Expand Down

0 comments on commit 21b23ae

Please sign in to comment.