mirror of
https://github.com/kjuulh/dagger-rs.git
synced 2024-11-25 16:32:42 +01:00
with codegen output
This commit is contained in:
parent
e5874141b3
commit
0bf6b0e91e
@ -1,10 +1,9 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use genco::{prelude::rust, quote, quote_in};
|
||||
use genco::{prelude::rust, quote};
|
||||
use graphql_introspection_query::introspection_response::{
|
||||
FullType, IntrospectionResponse, Schema,
|
||||
};
|
||||
use itertools::Itertools;
|
||||
|
||||
use crate::{
|
||||
handlers::{scalar::Scalar, DynHandler, Handlers},
|
||||
@ -47,7 +46,6 @@ impl CodeGeneration {
|
||||
for t in types {
|
||||
if let Some(_) = self.type_name(&t) {
|
||||
let rendered = handler.render(&t)?;
|
||||
|
||||
output.push();
|
||||
output.append(rendered);
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ impl Handler for Scalar {
|
||||
let name = t.name.as_ref().ok_or(eyre::anyhow!("name not found"))?;
|
||||
|
||||
Ok(quote! {
|
||||
pub struct $name (Scalar);
|
||||
pub struct $name(Scalar);
|
||||
})
|
||||
}
|
||||
|
||||
|
23
crates/dagger-sdk/src/gen.rs
Normal file
23
crates/dagger-sdk/src/gen.rs
Normal file
@ -0,0 +1,23 @@
|
||||
// code generated by dagger. DO NOT EDIT.
|
||||
|
||||
/// A content-addressed socket identifier.
|
||||
pub struct SocketID(Scalar);
|
||||
|
||||
/// The platform config OS and architecture in a Container.
|
||||
/// The format is [os]/[platform]/[version] (e.g. darwin/arm64/v7, windows/amd64, linux/arm64).
|
||||
pub struct Platform(Scalar);
|
||||
|
||||
/// A unique container identifier. Null designates an empty container (scratch).
|
||||
pub struct ContainerID(Scalar);
|
||||
|
||||
/// A content-addressed directory identifier.
|
||||
pub struct DirectoryID(Scalar);
|
||||
|
||||
/// A unique identifier for a secret.
|
||||
pub struct SecretID(Scalar);
|
||||
|
||||
/// A file identifier.
|
||||
pub struct FileID(Scalar);
|
||||
|
||||
/// A global cache volume identifier.
|
||||
pub struct CacheID(Scalar);
|
@ -1,3 +1,5 @@
|
||||
pub mod gen;
|
||||
|
||||
pub fn add(left: usize, right: usize) -> usize {
|
||||
left + right
|
||||
}
|
||||
|
@ -1,3 +1,5 @@
|
||||
use std::io::Write;
|
||||
|
||||
use clap::{Arg, ArgMatches};
|
||||
use dagger_codegen::codegen::CodeGeneration;
|
||||
|
||||
@ -21,7 +23,8 @@ impl GenerateCommand {
|
||||
let code = CodeGeneration::new().generate(&schema)?;
|
||||
|
||||
if let Some(output) = arg_matches.get_one::<String>("output") {
|
||||
// TODO: Write to file
|
||||
let mut file = std::fs::File::create(output)?;
|
||||
file.write(code.as_bytes())?;
|
||||
} else {
|
||||
println!("{}", code);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user