Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion .github/workflows/netsukefile-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ jobs:
command: "touch generated.txt"
MANIFEST
- name: Run Netsuke
run: ./target/debug/netsuke build generated.txt
run: ./target/debug/netsuke --verbose build generated.txt
- name: Assert artefact exists
run: scripts/assert-file-exists.sh generated.txt
134 changes: 134 additions & 0 deletions Cargo.lock

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

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ thiserror = "1"
sha2 = "0.10"
itoa = "1"
itertools = "0.12"
tracing = "0.1"
tracing-subscriber = { version = "0.3", features = ["fmt"] }
serde_json = "1"

[lints.clippy]
pedantic = { level = "warn", priority = -1 }
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ You can also pass:
- `--file` to use an alternate manifest
- `--directory` to run in a different working dir
- `-j N` to control parallelism (passed through to Ninja)
- `-v`, `--verbose` to enable verbose logging

## 🚧 Status

Expand Down
5 changes: 5 additions & 0 deletions docs/netsuke-design.md
Original file line number Diff line number Diff line change
Expand Up @@ -1369,6 +1369,10 @@ struct Cli { /// Path to the Netsuke manifest file to use.
#[arg(short, long, value_name = "N")]
jobs: Option<usize>,

/// Enable verbose logging output.
#[arg(short, long)]
verbose: bool,
Comment on lines +1372 to +1374
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.

🧹 Nitpick (assertive)

Clarify --verbose flag behaviour within the prose sections

Add one or two sentences in Section 8.3 (Command Behaviour) explaining exactly what enabling -v/--verbose does at runtime: initialises a tracing_subscriber, raises the global log level to DEBUG, and emits the extra diagnostics listed in the PR (AST dump, Ninja path, Ninja invocation). This keeps the narrative part of the design document in sync with the updated code snippet.

🤖 Prompt for AI Agents
In docs/netsuke-design.md around lines 1372 to 1374, add one or two sentences in
Section 8.3 (Command Behaviour) that clearly explain the effect of the
`-v/--verbose` flag at runtime. Specify that enabling this flag initializes a
`tracing_subscriber`, raises the global log level to `DEBUG`, and causes the
program to emit additional diagnostics such as the AST dump, Ninja path, and
Ninja invocation, ensuring the prose matches the updated code behavior.


#[command(subcommand)]
command: Option<Commands>, }

Expand Down Expand Up @@ -1513,6 +1517,7 @@ selected for this project and the rationale for their inclusion.
| Templating | minijinja | High compatibility with Jinja2, minimal dependencies, and supports runtime template loading. |
| Shell Quoting | shell-quote | A critical security component; provides robust, shell-specific escaping for command arguments. |
| Error Handling | anyhow + thiserror | An idiomatic and powerful combination for creating rich, contextual, and user-friendly error reports. |
| Logging | tracing | Structured, levelled diagnostic output for debugging and insight. |
| Versioning | semver | The standard library for parsing and evaluating Semantic Versioning strings, essential for the `netsuke_version` field. |

### 9.3 Future Enhancements
Expand Down
10 changes: 5 additions & 5 deletions src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
//! ```

use semver::Version;
use serde::{Deserialize, de::Deserializer};
use serde::{Deserialize, Serialize, de::Deserializer};

fn deserialize_actions<'de, D>(deserializer: D) -> Result<Vec<Target>, D::Error>
where
Expand Down Expand Up @@ -53,7 +53,7 @@
/// assert_eq!(manifest.targets.len(), 1);
/// # Ok(()) }
/// ```
#[derive(Debug, Deserialize)]
#[derive(Debug, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
Comment on lines +56 to 57
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.

⚠️ Potential issue

Fix build: implement Serialize for Recipe before deriving it here

NetsukeManifest (and the other structs below) embed Recipe through #[serde(flatten)]. Adding Serialize here triggers E0277 because Recipe itself is not serialisable.
Derive or hand-implement Serialize for Recipe (annotate it with #[derive(Serialize)] plus #[serde(untagged)], or provide a manual impl mirroring the custom Deserialize) before keeping Serialize in these outer structs.

@@
 #[derive(Debug, Clone, PartialEq)]
-pub enum Recipe {
+#[derive(Debug, Clone, PartialEq, Serialize)]
+#[serde(untagged)]
+pub enum Recipe {

Failing to do this blocks compilation and the CI pipeline.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
#[derive(Debug, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
#[derive(Debug, Clone, PartialEq, Serialize)]
#[serde(untagged)]
pub enum Recipe {
// existing variants…
}
🤖 Prompt for AI Agents
In src/ast.rs around lines 56 to 57, the Recipe struct is missing a Serialize
implementation, causing a compilation error when outer structs derive Serialize
and flatten Recipe. To fix this, add #[derive(Serialize)] and #[serde(untagged)]
annotations to the Recipe struct or provide a manual Serialize implementation
that matches its Deserialize logic. This will allow the outer structs to derive
Serialize without errors and fix the build failure.

pub struct NetsukeManifest {
/// Semantic version of the manifest format.
Expand Down Expand Up @@ -86,7 +86,7 @@
/// targets. It may define a command line, a script block, or delegate to another
/// named rule. Dependencies may be specified as either a single string or a
/// list of strings.
#[derive(Debug, Deserialize)]
#[derive(Debug, Deserialize, Serialize)]

Check failure on line 89 in src/ast.rs

View workflow job for this annotation

GitHub Actions / netsukefile

the trait bound `Recipe: Serialize` is not satisfied

Check failure on line 89 in src/ast.rs

View workflow job for this annotation

GitHub Actions / build-test

the trait bound `ast::Recipe: ast::_::_serde::Serialize` is not satisfied
#[serde(deny_unknown_fields)]
pub struct Rule {
/// Unique identifier used by targets to reference this rule.
Expand Down Expand Up @@ -164,7 +164,7 @@
/// Targets describe the files produced by a rule and their dependencies.
/// `phony` targets are always considered out of date, while `always` targets are
/// regenerated even if their inputs are unchanged.
#[derive(Debug, Deserialize)]
#[derive(Debug, Deserialize, Serialize)]

Check failure on line 167 in src/ast.rs

View workflow job for this annotation

GitHub Actions / netsukefile

the trait bound `Recipe: Serialize` is not satisfied

Check failure on line 167 in src/ast.rs

View workflow job for this annotation

GitHub Actions / build-test

the trait bound `ast::Recipe: ast::_::_serde::Serialize` is not satisfied
#[serde(deny_unknown_fields)]
pub struct Target {
/// Output file or files.
Expand Down Expand Up @@ -212,7 +212,7 @@
/// - hello
/// - world
/// ```
#[derive(Debug, Deserialize, Default, Clone, PartialEq)]
#[derive(Debug, Deserialize, Serialize, Default, Clone, PartialEq)]
#[serde(untagged)]
pub enum StringOrList {
/// No value provided.
Expand Down
4 changes: 4 additions & 0 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ pub struct Cli {
#[arg(short, long, value_name = "N", value_parser = parse_jobs)]
pub jobs: Option<usize>,

/// Enable verbose logging output.
#[arg(short, long)]
pub verbose: bool,

#[command(subcommand)]
pub command: Option<Commands>,
}
Expand Down
5 changes: 5 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,14 @@

use netsuke::{cli::Cli, runner};
use std::process::ExitCode;
use tracing::Level;
use tracing_subscriber::fmt;

fn main() -> ExitCode {
let cli = Cli::parse_with_default();
if cli.verbose {
fmt().with_max_level(Level::DEBUG).init();
}
match runner::run(&cli) {
Ok(()) => ExitCode::SUCCESS,
Err(err) => {
Expand Down
Loading
Loading