mirror of
https://github.com/kjuulh/dagger-rs.git
synced 2024-11-25 16:32:42 +01:00
with type filtering
This commit is contained in:
parent
3eb891422f
commit
2eb5d98c8a
@ -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
|
||||
|
@ -1,3 +1,5 @@
|
||||
use crate::cli_generate;
|
||||
|
||||
pub struct Cli {
|
||||
cmd: clap::Command,
|
||||
}
|
||||
@ -7,7 +9,7 @@ impl Cli {
|
||||
Ok(Self {
|
||||
cmd: clap::Command::new("dagger-rust")
|
||||
.subcommand_required(true)
|
||||
.subcommand(clap::Command::new("generate")),
|
||||
.subcommand(cli_generate::GenerateCommand::new_cmd()),
|
||||
})
|
||||
}
|
||||
|
||||
@ -15,8 +17,10 @@ impl Cli {
|
||||
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
src/cli_generate.rs
Normal file
30
src/cli_generate.rs
Normal file
@ -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(())
|
||||
}
|
||||
}
|
4709
src/code_generation.rs
Normal file
4709
src/code_generation.rs
Normal file
File diff suppressed because it is too large
Load Diff
@ -7,6 +7,12 @@ pub struct Config {
|
||||
pub execute_timeout_ms: Option<u64>,
|
||||
}
|
||||
|
||||
impl Default for Config {
|
||||
fn default() -> Self {
|
||||
Self::new(None, None, None, None)
|
||||
}
|
||||
}
|
||||
|
||||
impl Config {
|
||||
pub fn new(
|
||||
workdir_path: Option<PathBuf>,
|
||||
|
@ -1,5 +1,7 @@
|
||||
pub mod cli;
|
||||
mod cli_generate;
|
||||
mod cli_session;
|
||||
mod code_generation;
|
||||
mod config;
|
||||
mod connect_params;
|
||||
pub mod dagger;
|
||||
|
@ -8,7 +8,7 @@ pub fn get_schema() -> eyre::Result<IntrospectionResponse> {
|
||||
//TODO: Implement context for proc
|
||||
let (conn, _proc) = Engine::new().start(&cfg)?;
|
||||
let session = Session::new();
|
||||
let req_builder = session.start(cfg, &conn)?;
|
||||
let req_builder = session.start(&cfg, &conn)?;
|
||||
let schema = session.schema(req_builder)?;
|
||||
|
||||
Ok(schema)
|
||||
|
@ -23,7 +23,7 @@ impl Session {
|
||||
Self {}
|
||||
}
|
||||
|
||||
pub fn start(&self, _cfg: Config, conn: &ConnectParams) -> eyre::Result<RequestBuilder> {
|
||||
pub fn start(&self, _cfg: &Config, conn: &ConnectParams) -> eyre::Result<RequestBuilder> {
|
||||
let client = Client::builder()
|
||||
.user_agent("graphql-rust/0.10.0")
|
||||
.connection_verbose(true)
|
||||
|
Loading…
Reference in New Issue
Block a user