-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add gds2{json,yaml,toml} CLIs. Upgrade to clap v4.0.
- Loading branch information
1 parent
9042bb8
commit 56e40c6
Showing
8 changed files
with
178 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
//! | ||
//! # GDSII to JSON Conversion CLI | ||
//! | ||
//! Converts a GDSII file to [`gds21::GdsLibrary`] JSON. | ||
//! | ||
use clap::Parser; | ||
use std::error::Error; | ||
|
||
// Use our own crate, note by name, not `crate::` or `super::`. | ||
use layout21converters::gds_serialization::{convert, ConvOptions}; | ||
|
||
// => The doc-comment on `ProgramOptions` here is displayed by the `clap`-generated help docs => | ||
|
||
/// # GDSII to JSON Conversion CLI | ||
/// Converts a GDSII file to [`gds21::GdsLibrary`] JSON. | ||
#[derive(Parser)] | ||
pub struct ProgramOptions { | ||
/// GDS Input File | ||
#[arg(short = 'i', long, default_value = "")] | ||
pub gds: String, | ||
/// Output File | ||
#[arg(short = 'o', long, default_value = "")] | ||
pub out: String, | ||
/// Verbose Output Mode | ||
#[arg(short, long)] | ||
pub verbose: bool, | ||
} | ||
|
||
impl Into<ConvOptions> for ProgramOptions { | ||
/// Convert into the [`gds_serialization::ConvOptions`] struct. | ||
fn into(self) -> ConvOptions { | ||
ConvOptions { | ||
gds: self.gds, | ||
fmt: "json".to_string(), // <= this is kinda the whole program right here! | ||
out: self.out, | ||
verbose: self.verbose, | ||
} | ||
} | ||
} | ||
|
||
/// Main entry point. | ||
/// Parses the command-line arguments and calls [`gds_serialization::convert`]. | ||
pub fn main() -> Result<(), Box<dyn Error>> { | ||
let options = ProgramOptions::parse(); | ||
convert(&options.into()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
//! | ||
//! # GDSII to TOML Conversion CLI | ||
//! | ||
//! Converts a GDSII file to [`gds21::GdsLibrary`] TOML. | ||
//! | ||
use clap::Parser; | ||
use std::error::Error; | ||
|
||
// Use our own crate, note by name, not `crate::` or `super::`. | ||
use layout21converters::gds_serialization::{convert, ConvOptions}; | ||
|
||
// => The doc-comment on `ProgramOptions` here is displayed by the `clap`-generated help docs => | ||
|
||
/// # GDSII to TOML Conversion CLI | ||
/// Converts a GDSII file to [`gds21::GdsLibrary`] TOML. | ||
#[derive(Parser)] | ||
pub struct ProgramOptions { | ||
/// GDS Input File | ||
#[arg(short = 'i', long, default_value = "")] | ||
pub gds: String, | ||
/// Output File | ||
#[arg(short = 'o', long, default_value = "")] | ||
pub out: String, | ||
/// Verbose Output Mode | ||
#[arg(short, long)] | ||
pub verbose: bool, | ||
} | ||
|
||
impl Into<ConvOptions> for ProgramOptions { | ||
/// Convert into the [`gds_serialization::ConvOptions`] struct. | ||
fn into(self) -> ConvOptions { | ||
ConvOptions { | ||
gds: self.gds, | ||
fmt: "toml".to_string(), // <= this is kinda the whole program right here! | ||
out: self.out, | ||
verbose: self.verbose, | ||
} | ||
} | ||
} | ||
|
||
/// Main entry point. | ||
/// Parses the command-line arguments and calls [`gds_serialization::convert`]. | ||
pub fn main() -> Result<(), Box<dyn Error>> { | ||
let options = ProgramOptions::parse(); | ||
convert(&options.into()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
//! | ||
//! # GDSII to YAML Conversion CLI | ||
//! | ||
//! Converts a GDSII file to [`gds21::GdsLibrary`] YAML. | ||
//! | ||
use clap::Parser; | ||
use std::error::Error; | ||
|
||
// Use our own crate, note by name, not `crate::` or `super::`. | ||
use layout21converters::gds_serialization::{convert, ConvOptions}; | ||
|
||
// => The doc-comment on `ProgramOptions` here is displayed by the `clap`-generated help docs => | ||
|
||
/// # GDSII to YAML Conversion CLI | ||
/// Converts a GDSII file to [`gds21::GdsLibrary`] YAML. | ||
#[derive(Parser)] | ||
pub struct ProgramOptions { | ||
/// GDS Input File | ||
#[arg(short = 'i', long, default_value = "")] | ||
pub gds: String, | ||
/// Output File | ||
#[arg(short = 'o', long, default_value = "")] | ||
pub out: String, | ||
/// Verbose Output Mode | ||
#[arg(short, long)] | ||
pub verbose: bool, | ||
} | ||
|
||
impl Into<ConvOptions> for ProgramOptions { | ||
/// Convert into the [`gds_serialization::ConvOptions`] struct. | ||
fn into(self) -> ConvOptions { | ||
ConvOptions { | ||
gds: self.gds, | ||
fmt: "yaml".to_string(), // <= this is kinda the whole program right here! | ||
out: self.out, | ||
verbose: self.verbose, | ||
} | ||
} | ||
} | ||
|
||
/// Main entry point. | ||
/// Parses the command-line arguments and calls [`gds_serialization::convert`]. | ||
pub fn main() -> Result<(), Box<dyn Error>> { | ||
let options = ProgramOptions::parse(); | ||
convert(&options.into()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters