Skip to content

Commit

Permalink
feat(hugr-cli)!: allow registry specification in run_dump (#1501)
Browse files Browse the repository at this point in the history
To allow downstream cli tools to dump their own extensions.

BREAKING CHANGE: `ExtArgs::run_dump` now takes the registry to dump as
an argument.
  • Loading branch information
ss2165 committed Sep 3, 2024
1 parent a32bd84 commit be9e2be
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions hugr-cli/src/extensions.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//! Dump standard extensions in serialized form.
use clap::Parser;
use hugr_core::extension::ExtensionRegistry;
use std::{io::Write, path::PathBuf};

/// Dump the standard extensions.
Expand All @@ -24,10 +25,10 @@ impl ExtArgs {
/// Write out the standard extensions in serialized form.
/// Qualified names of extensions used to generate directories under the specified output directory.
/// E.g. extension "foo.bar.baz" will be written to "OUTPUT/foo/bar/baz.json".
pub fn run_dump(&self) {
pub fn run_dump(&self, registry: &ExtensionRegistry) {
let base_dir = &self.outdir;

for (name, ext) in hugr_core::std_extensions::STD_REG.iter() {
for (name, ext) in registry.iter() {
let mut path = base_dir.clone();
for part in name.split('.') {
path.push(part);
Expand Down
2 changes: 1 addition & 1 deletion hugr-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use clap_verbosity_flag::Level;
fn main() {
match CliArgs::parse() {
CliArgs::Validate(args) => run_validate(args),
CliArgs::GenExtensions(args) => args.run_dump(),
CliArgs::GenExtensions(args) => args.run_dump(&hugr_core::std_extensions::STD_REG),
CliArgs::Mermaid(mut args) => args.run_print().unwrap(),
CliArgs::External(_) => {
// TODO: Implement support for external commands.
Expand Down

0 comments on commit be9e2be

Please sign in to comment.