-
Notifications
You must be signed in to change notification settings - Fork 3
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
Feature/cli integration #55
base: main
Are you sure you want to change the base?
Conversation
Add Then you will be able to create a default instance like use snmp_sim::configuration::Settings;
let settings = Settings::default(); But to have some meaningful configuration values, you need to set serde::default for each struct fields. #[derive(serde::Deserialize, Clone, Default)]
/// Structure representing the database settings
pub struct DatabaseSettings {
/// database connection URI
#[serde(default = "default_connection_uri")]
connection_uri: String,
#[serde(default = "default_tests_skip_drop")]
pub tests_skip_drop: bool,
}
fn default_connection_uri() -> String {
"sqlite://~/.snmp-sim/snmp-sim.db".to_string()
} You can consider the base.yaml as default values. |
src/cli/cli.rs
Outdated
fo, | ||
}; | ||
} | ||
Err(err) => panic!("This file already exists {:?}", err); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't use panic!
in production, but propagate the error instead.
The error should inform user, that the file already exists, and if it is intended to be overwritten, then the y
argument needs to be involved.
src/cli/cli.rs
Outdated
} | ||
Err(err) => panic!("This file already exists {:?}", err); | ||
} | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm missing the write to file part of the code
4d30f22
to
f27af7a
Compare
src/cli/cli.rs
Outdated
use std::io::ErrorKind; | ||
use std::path::Path; | ||
|
||
// fn write_data_to_file() -> Result<(), serde::yaml::Error> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove the commented code
src/main.rs
Outdated
use snmp_sim::app::Service; | ||
use snmp_sim::configuration::get_configuration; | ||
|
||
#[derive(Parser, Debug)] | ||
#[clap(about, version, author)] | ||
struct Value {/* To be filled with args/values */} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
implement the SNMP Simulator service CLI
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and handle the CLI from ./src/main.rs
Altered main.rs to add derive api macro and clap macro, in order to prep for integrating clap.