Skip to content

Commit

Permalink
feat: add module for objects common between clts and wfs
Browse files Browse the repository at this point in the history
  • Loading branch information
onnovalkering committed Mar 19, 2020
1 parent e9e5095 commit ea31209
Show file tree
Hide file tree
Showing 4 changed files with 198 additions and 159 deletions.
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
extern crate failure;

pub mod v11_clt;
pub mod v11_cm;
pub mod v11_wf;
pub mod v11;
124 changes: 39 additions & 85 deletions src/v11_clt.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use crate::v11_cm::{Any, CwlType, Documentation, Format, SecondaryFiles};
use serde::{Deserialize, Serialize};
use serde_with::skip_serializing_none;
use serde_yaml::Value as YValue;
Expand All @@ -16,9 +17,9 @@ pub struct CommandLineTool {

pub cwl_version: String,

pub doc: Option<CommandLineToolDoc>,
pub doc: Option<Documentation>,

pub hints: Option<YValue>,
pub hints: Option<YValue>, // TODO

pub id: Option<String>,

Expand All @@ -30,13 +31,13 @@ pub struct CommandLineTool {

pub permanent_fail_codes: Option<Vec<u32>>,

pub requirements: Option<YValue>,
pub requirements: Option<YValue>, // TODO

pub stderr: Option<CommandLineToolStderr>,
pub stderr: Option<String>,

pub stdin: Option<CommandLineToolStdin>,
pub stdin: Option<String>,

pub stdout: Option<CommandLineToolStdout>,
pub stdout: Option<String>,

pub success_codes: Option<Vec<u32>>,

Expand All @@ -47,8 +48,7 @@ pub struct CommandLineTool {
#[derive(Clone, Debug, Deserialize, Serialize)]
pub enum CommandLineToolArgument {
Argument(String),
Expression(YValue),
CommandLineBinding(CommandLineBinding),
Binding(CommandLineBinding),
}

#[skip_serializing_none]
Expand All @@ -67,54 +67,40 @@ pub struct CommandLineBinding {

pub shell_quote: Option<bool>,

pub value_from: Option<CommandLineBindingValueFrom>,
pub value_from: Option<String>,
}

#[serde(untagged, rename_all = "camelCase")]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub enum CommandLineBindingPosition {
Position(u32),
Expression(YValue)
}

#[serde(untagged, rename_all = "camelCase")]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub enum CommandLineBindingValueFrom {
ValueFrom(String),
Expression(YValue)
Expression(String)
}

#[serde(untagged, rename_all = "camelCase")]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub enum CommandLineToolBaseCommand {
BaseCommand(String),
Array(Vec<String>)
}

#[serde(untagged, rename_all = "camelCase")]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub enum CommandLineToolDoc {
Doc(String),
Array(Vec<String>)
Command(String),
CommandWithArguments(Vec<String>)
}

#[serde(untagged, rename_all = "camelCase")]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub enum CommandLineToolInput {
Array(Vec<CommandInputParameter>),
Map(Map<CommandInputParameter>),
Types(Map<YValue>)
ParameterArray(Vec<CommandInputParameter>),
ParameterMap(Map<CommandInputParameter>),
TypeMap(Map<CommandLineToolInputType>)
}

#[skip_serializing_none]
#[serde(rename_all = "camelCase")]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct CommandInputParameter {
pub default: Option<YValue>,
pub default: Option<Any>,

pub doc: Option<CommandLineToolDoc>,
pub doc: Option<Documentation>,

pub format: Option<CommandLineParameterFormat>,
pub format: Option<Format>,

pub id: Option<String>,

Expand All @@ -126,58 +112,42 @@ pub struct CommandInputParameter {

pub load_listing: Option<String>,

#[serde(rename = "type")]
pub param_type: YValue,
pub r#type: CommandInputParameterType,

pub secondary_files: Option<CommandLineSecondaryFiles>,
pub secondary_files: Option<SecondaryFiles>,

pub streamable: Option<bool>,
}

#[serde(untagged, rename_all = "camelCase")]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub enum CommandLineSecondaryFiles {
SecondaryFile(SecondaryFileSchema),
Array(Vec<SecondaryFileSchema>),
}

#[skip_serializing_none]
#[serde(rename_all = "camelCase")]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct SecondaryFileSchema {
pub pattern: SecondaryFileSchemaPattern,
pub required: Option<SecondaryFileSchemaRequired>
pub enum CommandInputParameterType {
Type(CommandLineToolInputType),
TypeArray(Vec<CommandLineToolInputType>)
}

#[serde(untagged, rename_all = "camelCase")]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub enum SecondaryFileSchemaPattern {
Pattern(String),
Expression(YValue)
}

#[serde(untagged, rename_all = "camelCase")]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub enum SecondaryFileSchemaRequired {
Required(bool),
Expression(YValue)
pub enum CommandLineToolInputType {
CwlType(CwlType),
Schema(YValue), // TODO
}

#[serde(untagged, rename_all = "camelCase")]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub enum CommandLineToolOutput {
Array(Vec<CommandOutputParameter>),
Map(Map<CommandOutputParameter>),
Types(Map<YValue>)
ParameterArray(Vec<CommandOutputParameter>),
ParameterMap(Map<CommandOutputParameter>),
TypeMap(Map<CommandLineToolOutputType>)
}

#[skip_serializing_none]
#[serde(rename_all = "camelCase")]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct CommandOutputParameter {
pub doc: Option<CommandLineToolDoc>,
pub doc: Option<Documentation>,

pub format: Option<CommandLineParameterFormat>,
pub format: Option<Format>,

pub id: Option<String>,

Expand All @@ -189,39 +159,23 @@ pub struct CommandOutputParameter {

pub load_listing: Option<String>,

#[serde(rename = "type")]
pub param_type: YValue,
pub r#type: CommandOutputParameterType,

pub secondary_files: Option<CommandLineSecondaryFiles>,
pub secondary_files: Option<SecondaryFiles>,

pub streamable: Option<bool>,
}

#[serde(untagged, rename_all = "camelCase")]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub enum CommandLineParameterFormat {
Format(String),
Array(Vec<String>),
Expression(YValue),
pub enum CommandOutputParameterType {
Type(CommandLineToolOutputType),
TypeArray(Vec<CommandLineToolOutputType>)
}

#[serde(untagged, rename_all = "camelCase")]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub enum CommandLineToolStderr {
Stderr(String),
Expression(YValue)
}

#[serde(rename_all = "camelCase")]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub enum CommandLineToolStdin {
Stdin(String),
Expression(YValue)
}

#[serde(rename_all = "camelCase")]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub enum CommandLineToolStdout {
Stdout(String),
Expression(YValue)
pub enum CommandLineToolOutputType {
CwlType(CwlType),
Schema(YValue), // TODO
}
110 changes: 110 additions & 0 deletions src/v11_cm.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
use serde::{Deserialize, Serialize};
use serde_with::skip_serializing_none;
use serde_yaml::Value as YValue;

#[serde(untagged, rename_all = "camelCase")]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub enum SecondaryFiles {
Schema(SecondaryFileSchema),
Schemas(Vec<SecondaryFileSchema>),
}

#[skip_serializing_none]
#[serde(rename_all = "camelCase")]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct SecondaryFileSchema {
pattern: String,
required: SecondaryFileSchemaRequired,
}

#[serde(untagged, rename_all = "camelCase")]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub enum SecondaryFileSchemaRequired {
Boolean(bool),
Expression(String),
}

#[serde(untagged, rename_all = "camelCase")]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub enum Any {
Any(YValue)
}

#[serde(untagged, rename_all = "camelCase")]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub enum CwlType {
Null,
Boolean(bool),
Int(i32),
Long(i64),
Float(f32),
Double(f64),
Str(String),
File(File),
Directory(Directory),
}

#[skip_serializing_none]
#[serde(rename_all = "camelCase")]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct File {
pub class: String,

pub location: Option<String>,

pub path: Option<String>,

pub basename: Option<String>,

pub dirname: Option<String>,

pub nameroot: Option<String>,

pub nameext: Option<String>,

pub checksum: Option<String>,

pub size: Option<i64>,

pub secondary_files: Option<Vec<FileOrDirectory>>,

pub format: Option<String>,

pub contents: Option<String>,
}

#[skip_serializing_none]
#[serde(rename_all = "camelCase")]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct Directory {
pub class: String,

pub location: Option<String>,

pub path: Option<String>,

pub basename: Option<String>,

pub listing: Option<Vec<FileOrDirectory>>,
}

#[serde(untagged, rename_all = "camelCase")]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub enum FileOrDirectory {
File(File),
Directory(Directory),
}

#[serde(untagged, rename_all = "camelCase")]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub enum Documentation {
SingleLine(String),
MultiLine(Vec<String>)
}

#[serde(untagged, rename_all = "camelCase")]
#[derive(Clone, Debug, Deserialize, Serialize)]
pub enum Format {
Format(String),
Formats(Vec<String>),
}
Loading

0 comments on commit ea31209

Please sign in to comment.