Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
13 changes: 13 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions binaries/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ python = ["pyo3"]
arrow = { workspace = true }
clap = { version = "4.0.3", features = ["derive"] }
clap_complete = "4.5.61"
enum_dispatch = "0.3.13"
eyre = "0.6.8"
dora-core = { workspace = true, features = ["zenoh"] }
dora-message = { workspace = true }
Expand Down
36 changes: 6 additions & 30 deletions binaries/cli/src/command/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ mod topic;
mod up;

pub use build::build;
pub use run::{run, run_func};
pub use run::run;

use build::Build;
use check::Check;
Expand All @@ -35,10 +35,11 @@ use runtime::Runtime;
use self_::SelfSubCommand;
use start::Start;
use stop::Stop;
use topic::Topic;
use topic::{Echo, Hz, List, Topic};
use up::Up;

/// dora-rs cli client
#[enum_dispatch::enum_dispatch(Executable)]
#[derive(Debug, clap::Subcommand)]
pub enum Command {
Check(Check),
Expand Down Expand Up @@ -67,10 +68,8 @@ pub enum Command {
Topic(Topic),

Completion(Completion),
Self_ {
#[clap(subcommand)]
command: SelfSubCommand,
},
#[clap(subcommand)]
Self_(SelfSubCommand),
}

fn default_tracing() -> eyre::Result<()> {
Expand All @@ -86,30 +85,7 @@ fn default_tracing() -> eyre::Result<()> {
Ok(())
}

#[enum_dispatch::enum_dispatch]
pub trait Executable {
fn execute(self) -> eyre::Result<()>;
}

impl Executable for Command {
fn execute(self) -> eyre::Result<()> {
match self {
Command::Check(args) => args.execute(),
Command::Coordinator(args) => args.execute(),
Command::Graph(args) => args.execute(),
Command::Build(args) => args.execute(),
Command::New(args) => args.execute(),
Command::Run(args) => args.execute(),
Command::Up(args) => args.execute(),
Command::Destroy(args) => args.execute(),
Command::Start(args) => args.execute(),
Command::Stop(args) => args.execute(),
Command::List(args) => args.execute(),
Command::Logs(args) => args.execute(),
Command::Daemon(args) => args.execute(),
Command::Self_ { command } => command.execute(),
Command::Runtime(args) => args.execute(),
Command::Topic(args) => args.execute(),
Command::Completion(args) => args.execute(),
}
}
}
5 changes: 0 additions & 5 deletions binaries/cli/src/command/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,6 @@ pub struct Run {
uv: bool,
}

#[deprecated(note = "use `run` instead")]
pub fn run_func(dataflow: String, uv: bool) -> eyre::Result<()> {
run(dataflow, uv)
}

pub fn run(dataflow: String, uv: bool) -> eyre::Result<()> {
#[cfg(feature = "tracing")]
{
Expand Down
16 changes: 2 additions & 14 deletions binaries/cli/src/command/topic.rs
Original file line number Diff line number Diff line change
@@ -1,27 +1,15 @@
use crate::command::{
Executable,
topic::{echo::Echo, hz::Hz, list::List},
};
pub use crate::command::topic::{echo::Echo, hz::Hz, list::List};

mod echo;
mod hz;
mod list;
mod selector;

/// Manage and inspect dataflow topics.
#[enum_dispatch::enum_dispatch(Executable)]
#[derive(Debug, clap::Subcommand)]
pub enum Topic {
List(List),
Echo(Echo),
Hz(Hz),
}

impl Executable for Topic {
fn execute(self) -> eyre::Result<()> {
match self {
Topic::List(cmd) => cmd.execute(),
Topic::Echo(cmd) => cmd.execute(),
Topic::Hz(cmd) => cmd.execute(),
}
}
}
2 changes: 1 addition & 1 deletion binaries/cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub mod session;
mod template;

pub use command::build;
pub use command::{run, run_func};
pub use command::run;

const LOCALHOST: IpAddr = IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1));
const LISTEN_WILDCARD: IpAddr = IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0));
Expand Down
2 changes: 1 addition & 1 deletion binaries/cli/src/output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ pub fn print_log_message(
let node_id = node_id
.to_string()
.bold()
.color(word_to_color(&node_id.to_string()));
.color(word_to_color(node_id.as_ref()));
let padding = if daemon.is_empty() { "" } else { " " };
format!("{node_id}{padding}{daemon}{colon} ")
}
Expand Down
Loading