Browse Source

add globbing support

Justin Tracey 1 year ago
parent
commit
a08eda471f
4 changed files with 8 additions and 7 deletions
  1. 1 0
      Cargo.toml
  2. 3 3
      shadow/client/shadow.yaml
  3. 2 2
      src/bin/mgen-client.rs
  4. 2 2
      src/bin/mgen-peer.rs

+ 1 - 0
Cargo.toml

@@ -5,6 +5,7 @@ edition = "2021"
 
 [dependencies]
 chrono = "0.4.24"
+glob = "0.3.1"
 rand = "0.8.5"
 rand_distr = { version = "0.4.3", features = ["serde1"] }
 rand_xoshiro = "0.6.0"

+ 3 - 3
shadow/client/shadow.yaml

@@ -24,17 +24,17 @@ hosts:
     network_node_id: 0
     processes:
     - path: mgen-client
-      args: alice-group1.toml alice-group2.toml
+      args: "*.toml"
       start_time: 5s
   client2:
     network_node_id: 0
     processes:
     - path: mgen-client
-      args: bob-group1.toml bob-group2.toml carol-group1.toml
+      args: "*.toml"
       start_time: 5s
   client3:
     network_node_id: 0
     processes:
     - path: mgen-client
-      args: dave-group2.toml
+      args: "*.toml"
       start_time: 5s

+ 2 - 2
src/bin/mgen-client.rs

@@ -218,8 +218,8 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
     let mut args = std::env::args();
     let _ = args.next();
     let mut handles = vec![];
-    for config_file in args {
-        let toml_s = std::fs::read_to_string(config_file)?;
+    for config_file in args.flat_map(|a| glob::glob(a.as_str()).unwrap()) {
+        let toml_s = std::fs::read_to_string(config_file?)?;
         let config = toml::from_str(&toml_s)?;
         let handle: task::JoinHandle<Result<(), MessengerError>> =
             tokio::spawn(manage_conversation(config));

+ 2 - 2
src/bin/mgen-peer.rs

@@ -322,8 +322,8 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
 
     let mut handles = vec![];
 
-    for config_file in args {
-        let toml_s = std::fs::read_to_string(config_file)?;
+    for config_file in args.flat_map(|a| glob::glob(a.as_str()).unwrap()) {
+        let toml_s = std::fs::read_to_string(config_file?)?;
         let config: Config = toml::from_str(&toml_s)?;
 
         let (reader_to_state, state_from_reader) = mpsc::unbounded_channel();