Skip to content
This repository has been archived by the owner on Jun 29, 2023. It is now read-only.

Commit

Permalink
with type filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
kjuulh committed Jan 28, 2023
1 parent 3eb8914 commit 2eb5d98
Show file tree
Hide file tree
Showing 8 changed files with 4,763 additions and 4 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,11 @@ A dagger sdk written in rust for rust.
## Disclaimer

Work in progress. This is not ready for usage yet

### Status

- [x] dagger cli downloader
- [x] dagger network session
- [ ] graphql rust codegen (User API)
- [ ] fix build / release cycle
- [ ] general api stabilisation
8 changes: 6 additions & 2 deletions src/cli.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use crate::cli_generate;

pub struct Cli {
cmd: clap::Command,
}
Expand All @@ -7,16 +9,18 @@ impl Cli {
Ok(Self {
cmd: clap::Command::new("dagger-rust")
.subcommand_required(true)
.subcommand(clap::Command::new("generate")),
.subcommand(cli_generate::GenerateCommand::new_cmd()),
})
}

pub fn execute(self, args: &[&str]) -> eyre::Result<()> {
let matches = self.cmd.get_matches_from(args);

match matches.subcommand() {
Some(("generate", _args)) => Ok(()),
Some(("generate", args)) => cli_generate::GenerateCommand::exec(args)?,
_ => eyre::bail!("command missing"),
}

Ok(())
}
}
30 changes: 30 additions & 0 deletions src/cli_generate.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
use clap::{Arg, ArgMatches};

use crate::{code_generation::CodeGeneration, config::Config, engine::Engine, session::Session};

#[allow(dead_code)]
pub struct GenerateCommand;

#[allow(dead_code)]
impl GenerateCommand {
pub fn new_cmd() -> clap::Command {
clap::Command::new("generate").arg(Arg::new("output").long("output"))
}

pub fn exec(arg_matches: &ArgMatches) -> eyre::Result<()> {
let cfg = Config::default();
let (conn, _proc) = Engine::new().start(&cfg)?;
let session = Session::new();
let req = session.start(&cfg, &conn)?;
let schema = session.schema(req)?;
let code = CodeGeneration::generate(&schema)?;

if let Some(output) = arg_matches.get_one::<String>("output") {
// TODO: Write to file
} else {
println!("{}", code);
}

Ok(())
}
}
Loading

0 comments on commit 2eb5d98

Please sign in to comment.