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

basic Twoliter.toml file #23

Merged
merged 1 commit into from
Jul 10, 2023
Merged

basic Twoliter.toml file #23

merged 1 commit into from
Jul 10, 2023

Conversation

webern
Copy link
Member

@webern webern commented Jul 9, 2023

Issue #, if available:

Closes #7

Description of changes:

Implement structs for a basic Twoliter.toml project file.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@webern webern mentioned this pull request Jul 9, 2023
Implement structs for a basic Twoliter.toml project file.
project_path: Option<PathBuf>,

/// The architecture to build for.
#[clap(long = "arch", default_value = "x86_64")]
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 possibly worth defaulting to the machine architecture.

Comment on lines +34 to +35
/// Recursively search for a file named `Twoliter.toml` starting in `dir`. If it is not found,
/// move up (i.e. `cd ..`) until it is found. Return an error if there is no parent directory.
Copy link
Contributor

Choose a reason for hiding this comment

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

Reading this I found myself wondering if Rust had TCO.

Presumably we would not encounter a directory structure in the wild that could blow the call stack, but I still learned something reading about it.

}
}

/// We need to constrain the `Project` struct to a valid version. Unfortunately `serde` does not
Copy link
Contributor

@cbgbt cbgbt Jul 10, 2023

Choose a reason for hiding this comment

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

This is clever (the good kind). Nice.

Comment on lines +52 to +56
// Move up a level and recurse.
let parent = dir
.parent()
.context("Unable to find Twoliter.toml file")?
.to_owned();
Copy link
Contributor

Choose a reason for hiding this comment

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

Potentially we could stop as soon as we reach a directory that has a .git subdirectory, since beyond that point it's unlikely we're going to find the Twoliter.toml that the user expects.

Comment on lines +88 to +89
#[derive(Default, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub(crate) struct SchemaVersion<const N: u32>;
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: this could be in a different module

@webern
Copy link
Member Author

webern commented Jul 10, 2023

I captured these ideas as issues for follow up.

@webern webern merged commit 209da2c into develop Jul 10, 2023
1 check passed
@webern webern deleted the project-file branch July 10, 2023 21:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

implement a basic project toml schema
3 participants