Skip to content

Add scaffold subcommand#36

Open
ludfjig wants to merge 1 commit intohyperlight-dev:mainfrom
ludfjig:scaffold
Open

Add scaffold subcommand#36
ludfjig wants to merge 1 commit intohyperlight-dev:mainfrom
ludfjig:scaffold

Conversation

@ludfjig
Copy link
Copy Markdown
Contributor

@ludfjig ludfjig commented Apr 1, 2026

Initial draft for a scaffolding command to create a ready-to-compile/run hyperlight project (with guest). Currently just targets 0.13. Might be useful in the future to decouple the templating from the template, so we can have multiple versions etc etc, and releasing a new hyperlight version won't need a new cargo-hyperlight release.

I plan to include this command in main hyperlight repo docs/markdown in something like the README.md or getting-started.md docs.

I'm particularly looking for feedback on the actual templated code. I made it slightly longer than I initially intended, but I think it makes sense given it shows off a lot important hyperlight features. I also think it makes sense to add a wit host+guest to this command as well, but can do that later

  • TODO, I'm not yet sure how to decide between using debug/release target folder for loading guest

Signed-off-by: Ludvig Liljenberg <4257730+ludfjig@users.noreply.github.com>
@ludfjig ludfjig requested a review from jprendes April 1, 2026 04:35
@ludfjig ludfjig marked this pull request as ready for review April 1, 2026 04:36
@ludfjig ludfjig requested a review from jsturtevant April 1, 2026 04:36
.file_name()
.context("Invalid project path")?
.to_str()
.context("Project name must be valid UTF-8")?;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

might want to do a bit more validation here on the name? I am not sure what makes up a valid project name but we would want to strip strings from beginning end etc. Maybe special characters?

use anyhow::{Context, Result, ensure};
use clap::Parser;

const HYPERLIGHT_VERSION: &str = "0.13";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

can we take this as input so we don't need to bump the tool everytime?

Copy link
Copy Markdown
Contributor Author

@ludfjig ludfjig Apr 6, 2026

Choose a reason for hiding this comment

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

I thought about this, but I'm not sure it makes sense, since we might have breaking changes. I think it's better we just bump it manually and at that time make sure the template is up to date. Perhaps we could do a quick check to make sure the version is the latest released version and add a warning if not to make users aware they are using an old version. Although this does require a cargo-hyperlight release for every hyperlight release, which I am unsure if we currently do.

Copy link
Copy Markdown
Contributor

@jsturtevant jsturtevant left a comment

Choose a reason for hiding this comment

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

I think this will make it much easier to get started and be successful! Did you consider any existing templating libraries in the eco system? This is pretty straight forward for now but there are often a lot of edge cases for projects that are larger.

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.

2 participants