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

Add keygen command. #9

Open
wants to merge 30 commits into
base: main
Choose a base branch
from
Open

Add keygen command. #9

wants to merge 30 commits into from

Conversation

ximon18
Copy link
Member

@ximon18 ximon18 commented Oct 17, 2024

WIP.

@ximon18 ximon18 requested a review from a team October 17, 2024 15:09
@ximon18 ximon18 mentioned this pull request Oct 17, 2024
12 tasks
@bal-e bal-e self-assigned this Oct 29, 2024
@bal-e bal-e added enhancement New feature or request needs-review labels Oct 29, 2024
@bal-e bal-e marked this pull request as ready for review October 29, 2024 15:27
src/commands/keygen.rs Outdated Show resolved Hide resolved
src/commands/keygen.rs Outdated Show resolved Hide resolved
src/commands/keygen.rs Show resolved Hide resolved
Copy link
Contributor

@tertsdiepraam tertsdiepraam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well done! It's not super pretty, but it's about what you can expect for so much IO. I'd love to see this tested before we merge this.

Cargo.toml Outdated Show resolved Hide resolved
src/commands/keygen.rs Show resolved Hide resolved
src/commands/keygen.rs Outdated Show resolved Hide resolved
src/commands/keygen.rs Outdated Show resolved Hide resolved
src/commands/keygen.rs Outdated Show resolved Hide resolved
src/commands/keygen.rs Show resolved Hide resolved
src/commands/keygen.rs Outdated Show resolved Hide resolved
public_key.algorithm().to_int(),
public_key.key_tag()
);
// TODO: Adjust for how 'Env' mocks the current directory.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's on main so you could do this (and make all this testable)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yeah, I need to rebase now.

src/commands/keygen.rs Outdated Show resolved Hide resolved
src/commands/keygen.rs Outdated Show resolved Hide resolved
make_ksk: bool,

/// Whether to create symlinks.
#[arg(short, long, value_enum, num_args = 0..=1, require_equals = true, default_missing_value = "yes", default_value = "no")]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you make the short = 's' and long = "symlink" explicit?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs a massive comment to explain the rest of the attributes you put on here as well.

algorithm = parse_os_with("algorithm (-a)", &parser.value()?, |s| {
Ok(match s {
"list" => {
// TODO: Mock stdout and process exit?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is possible after the notify branch is merged, where parse_ldns takes Env as well.


Arg::Short('r') => {
// NOTE: '-r' can be repeated; we don't use it, so the order doesn't matter.
let _ = parser.value()?;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to warn or error here? Sounds like something that could lead to unexpected behaviour.

Comment on lines +212 to +216
impl From<Keygen> for Command {
fn from(value: Keygen) -> Self {
Self::Keygen(value)
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I put all of these in commands/mod.rs, though maybe you're right it should be here.


/// Create a symlink, overwriting if it already exists.
#[cfg(unix)]
fn fs_symlink_force(&self, target: impl AsRef<Path>, link: impl AsRef<Path>) -> Result<()> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about adding higher-level API's than std here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request needs-review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants