Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding a basic CLI/TUI #1

Merged
merged 26 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
1c0af1a
Adding the initial cli
bjohnson5 Jul 11, 2024
2599c74
Adding run page and tab functionality to configure page
bjohnson5 Jul 13, 2024
6517229
Adding progress bar and payment chart to the terminal ui
bjohnson5 Jul 22, 2024
d7b2aa0
Refactoring cli
bjohnson5 Jul 23, 2024
4c888ff
Fixing simln library calls, adding blast_core to the cli
bjohnson5 Aug 5, 2024
64e2c10
Adding the start and stop network calls to cli, fixing logging
bjohnson5 Aug 5, 2024
c02a797
Refactoring the BlastTab trait and adding configure command placeholders
bjohnson5 Aug 6, 2024
f993b67
Fixing the command history
bjohnson5 Aug 6, 2024
1c6e398
Adding some initial commands and fixing hard coded paths
bjohnson5 Aug 7, 2024
a47803e
Fixing a build error
bjohnson5 Aug 7, 2024
e173bea
Adding data to the config tab, implementing some config commands
bjohnson5 Aug 7, 2024
365bf10
Reloading the available sims when opening the load tab
bjohnson5 Aug 7, 2024
005adc3
Sorting the event list by time
bjohnson5 Aug 7, 2024
75f01ae
Adding start and stop simulation commands to cli
bjohnson5 Aug 8, 2024
be3266f
Fixing the model log file
bjohnson5 Aug 8, 2024
002d641
Implementing the get model channels rpc
bjohnson5 Aug 8, 2024
f0dbd11
Implementing runtime statistics on the cli
bjohnson5 Aug 9, 2024
badad34
Small fixes
bjohnson5 Aug 10, 2024
b6f9229
Implementing simln stats
bjohnson5 Aug 16, 2024
529b0b7
Switching back to simln main branch
bjohnson5 Aug 21, 2024
24732ab
Updating go packages
bjohnson5 Sep 2, 2024
28b2a5b
Updating go dependencies
bjohnson5 Sep 21, 2024
4c5a720
Adding a loading page and a demo video
bjohnson5 Sep 24, 2024
cfc1333
Cleaning up some ui things
bjohnson5 Sep 25, 2024
de8636b
Implementing more configure commands
bjohnson5 Sep 27, 2024
f92abcf
Adding text wrapping to the output section of the configure page
bjohnson5 Sep 30, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

### Install Go
```bash
wget https://go.dev/dl/go1.22.2.linux-amd64.tar.gz
sudo tar -C /usr/local -xzf go1.22.2.linux-amd64.tar.gz
wget https://dl.google.com/go/go1.22.6.linux-amd64.tar.gz
sudo rm -rf /usr/local/go && sudo tar -C /usr/local -xzf go1.22.6.linux-amd64.tar.gz
export PATH=$PATH:/usr/local/go/bin
```

Expand Down
7 changes: 7 additions & 0 deletions blast_cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,10 @@ version = "0.1.0"
edition = "2021"

[dependencies]
blast_core = { path = "../blast_core" }
tokio = { version = "1.37.0", features = ["full"] }
simplelog = "0.12.2"
log = "0.4.20"
ratatui = "0.27.0"
anyhow = { version = "1.0.69", features = ["backtrace"] }
textwrap = "0.14"
9 changes: 8 additions & 1 deletion blast_cli/README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
# CLI
Run BLAST Simulations from the command line.
Run BLAST Simulations from the command line.

- `New` tab will let user choose what node types to use and how many
- `Load` tab will let user choose a sim
- `Configure` tab will only be accessible when a network is up and running (nodes/models) but the simulation is not running
- `Run` tab will only be accessible when a network is up and running AND the simulation is running

![](../images/blast_cli.gif)
56 changes: 56 additions & 0 deletions blast_cli/src/blast_cli.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// Blast libraries
use blast_core::Blast;

use crate::shared::*;
use crate::new::*;
use crate::load::*;
use crate::configure::*;
use crate::run::*;

pub struct BlastCli {
pub new: NewTab,
pub load: LoadTab,
pub config: ConfigureTab,
pub run: RunTab,
pub blast: Blast
}

impl BlastCli {
pub fn new() -> Self {
// Create the blast core object
let blast = Blast::new();

let mut model_list: Vec<Model> = Vec::new();
match blast.get_available_models() {
Ok(models) => {
for model_name in models {
model_list.push(Model{name: model_name.clone(), num_nodes: 0});
}
},
Err(_) => {}
}

let mut sim_list: Vec<String> = Vec::new();
match blast.get_available_sims() {
Ok(sims) => {
for name in sims {
sim_list.push(name);
}
},
Err(_) => {}
}

let nt = NewTab{models: StatefulList::with_items(model_list)};
let lt = LoadTab{sims: StatefulList::with_items(sim_list)};
let ct = ConfigureTab::new();
let rt = RunTab::new();

Self {
new: nt,
load: lt,
config: ct,
run: rt,
blast: blast
}
}
}
Loading