treewide: move rom's parser logic to cognos
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: I6a6a6964960ab80b5555a6cca7b20e11c8ac0ea2
This commit is contained in:
parent
c07b295f71
commit
5fea07c768
7 changed files with 57 additions and 119 deletions
|
|
@ -9,4 +9,13 @@ pub use aterm::{
|
|||
parse_drv_file,
|
||||
};
|
||||
pub use internal_json::{Actions, Activities, Id, Verbosity};
|
||||
pub use state::{BuildInfo, BuildStatus, Derivation, Host, State};
|
||||
pub use state::{BuildInfo, BuildStatus, Derivation, Host, OutputName, State, ProgressState};
|
||||
|
||||
/// Process a list of actions and return the resulting state
|
||||
pub fn process_actions(actions: Vec<Actions>) -> State {
|
||||
let mut state = State { progress: ProgressState::JustStarted };
|
||||
for action in actions {
|
||||
state.imbibe(action);
|
||||
}
|
||||
state
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,12 +18,14 @@ pub enum BuildStatus {
|
|||
Failed,
|
||||
}
|
||||
|
||||
pub enum Progress {
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
pub enum ProgressState {
|
||||
JustStarted,
|
||||
InputReceived,
|
||||
Finished,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
pub enum OutputName {
|
||||
Out,
|
||||
Doc,
|
||||
|
|
@ -36,9 +38,37 @@ pub enum OutputName {
|
|||
Other(String),
|
||||
}
|
||||
|
||||
impl OutputName {
|
||||
#[must_use]
|
||||
pub fn parse(name: &str) -> Self {
|
||||
match name.to_lowercase().as_str() {
|
||||
"out" => Self::Out,
|
||||
"doc" => Self::Doc,
|
||||
"dev" => Self::Dev,
|
||||
"bin" => Self::Bin,
|
||||
"info" => Self::Info,
|
||||
"lib" => Self::Lib,
|
||||
"man" => Self::Man,
|
||||
"dist" => Self::Dist,
|
||||
_ => Self::Other(name.to_string()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
pub enum Host {
|
||||
Local,
|
||||
Host(String),
|
||||
Localhost,
|
||||
Remote(String),
|
||||
}
|
||||
|
||||
impl Host {
|
||||
#[must_use]
|
||||
pub fn name(&self) -> &str {
|
||||
match self {
|
||||
Self::Localhost => "localhost",
|
||||
Self::Remote(name) => name,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Derivation {
|
||||
|
|
@ -65,9 +95,9 @@ pub struct Dependencies {
|
|||
|
||||
// #[derive(Default)]
|
||||
pub struct State {
|
||||
progress: Progress,
|
||||
pub progress: ProgressState,
|
||||
}
|
||||
|
||||
impl State {
|
||||
pub fn imbibe(&mut self, update: Actions) {}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue