Skip to content

Let weaveffi new scaffold the starter IDL in JSON or TOML #39

Description

@owenthcarey

Summary

WeaveFFI accepts IDLs in YAML, JSON, and TOML everywhere (weaveffi generate, validate, lint, and so on pick the parser from the file extension), but weaveffi new <name> always scaffolds weaveffi.yml. Users who keep their configs in JSON or TOML have to hand-convert the starter file.

Proposed change

Add an --idl-format <yaml|json|toml> flag (default yaml) to the New subcommand in crates/weaveffi-cli/src/main.rs and thread it into cmd_new in crates/weaveffi-cli/src/commands/new.rs. Rather than maintaining three hand-written string templates, the simplest robust approach is to parse the existing YAML starter with weaveffi_ir::parse::parse_api_str and re-serialize it in the requested format (the format command already does canonical serialization per format, see crates/weaveffi-cli/src/commands/format.rs for the pattern). Name the output file weaveffi.yml, weaveffi.json, or weaveffi.toml accordingly, and update the generated README and any printed next-step hints to reference the right filename.

Acceptance criteria

  • weaveffi new demo --idl-format toml produces a weaveffi.toml that passes weaveffi validate
  • Same for json; plain weaveffi new demo still produces the YAML file byte-identical to today's output
  • An invalid format value is rejected at argument parsing (use a clap ValueEnum)
  • Tests cover the three formats (see the existing CLI tests in crates/weaveffi-cli/src/main.rs or the tests in commands/new.rs if present)

Pointers

  • Subcommand definition: Commands::New in crates/weaveffi-cli/src/main.rs
  • Scaffolding logic and the starter IDL template: crates/weaveffi-cli/src/commands/new.rs
  • Canonical serialization per format: crates/weaveffi-cli/src/commands/format.rs

Suggested commit message

feat: let weaveffi new scaffold the starter IDL in JSON or TOML

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions