Skip to content

Commit

Permalink
👷 Upload the crate in GitHub Action (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
loxygenK committed May 25, 2022
1 parent d60eb1b commit f9db6c0
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 24 deletions.
9 changes: 4 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ jobs:
tag_name: ${{ steps.version-check.outputs.ver }}
token: ${{ secrets.PAT_TOKEN }}

# - name: Push to Cargo
# run: |
# cargo publish
# env:
# CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
- name: Push to Cargo
run: cargo publish
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[package]
name = "rxe"
version = "0.0.5"
version = "0.1.0"
edition = "2021"
license = "MIT"
description = "Easily customizable command runner made with Rust 🦀"
repository = "https://github.com/loxygenK/rxe"
keyword = ["runner", "task"]
keywords = ["runner", "task"]

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand Down
2 changes: 0 additions & 2 deletions src/cmd/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
pub(crate) mod exec;

use std::env;

pub struct Environment {
pub config_file: Option<String>,
pub args: Vec<String>
Expand Down
3 changes: 1 addition & 2 deletions src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use crate::helper::replace_iter::ReplaceIter;
#[derive(Debug, PartialEq)]
pub enum ParseStatus {
NotParsed,
ExpectingNext,
Parsed(ArgumentValue)
}

Expand Down Expand Up @@ -59,7 +58,7 @@ impl<'a> CommandParser<'a> {
Ok(Self { cmd, arg })
}

fn parse(mut self) -> Result<InputtedCommand, ParseError> {
fn parse(self) -> Result<InputtedCommand, ParseError> {
let mut args_status = self.cmd.args.iter()
.map(|x| (x.name.clone(), ParseStatus::NotParsed))
.collect::<HashMap<String, ParseStatus>>();
Expand Down
3 changes: 1 addition & 2 deletions src/config.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
use std::collections::HashMap;
use std::fmt::{Display, Formatter};
use std::fs;
use std::io::{self, ErrorKind, Read};
use std::io::{self, ErrorKind};

use serde::{Serialize, Deserialize};
use crate::command::ParseStatus::Parsed;

use crate::domain::{Constraints, Command, Argument, Config};

Expand Down
1 change: 0 additions & 1 deletion src/domain/argument_value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@ pub enum ArgumentValue {
Text(String),
Flag(bool),
Number(f64),
Choice(String)
}
15 changes: 7 additions & 8 deletions src/placeholder/fill.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::collections::HashMap;
use std::ops::Range;

use crate::{domain::ArgumentValue, constraints::{text::TextConstraint, Constraint, number::NumberConstraint, flag::FlagConstraint, choice::ChoiceConstraint}};
use crate::{domain::ArgumentValue, constraints::{text::TextConstraint, Constraint, number::NumberConstraint, flag::FlagConstraint}};

use super::{Placeholder, PlaceholderParseError};

Expand All @@ -10,10 +10,9 @@ pub(super) fn fill_first_placeholder(original: &str, values: &HashMap<String, Ar
let value = values.get(&placeholder.arg_name).ok_or(PlaceholderParseError::NotExistingArgument)?;

let filling_value = match value {
ArgumentValue::Text(t) => TextConstraint.fill_placeholder(value, &placeholder.args),
ArgumentValue::Number(t) => NumberConstraint.fill_placeholder(value, &placeholder.args),
ArgumentValue::Flag(t) => FlagConstraint.fill_placeholder(value, &placeholder.args),
ArgumentValue::Choice(t) => TextConstraint.fill_placeholder(value, &placeholder.args),
ArgumentValue::Text(_) => TextConstraint.fill_placeholder(value, &placeholder.args),
ArgumentValue::Number(_) => NumberConstraint.fill_placeholder(value, &placeholder.args),
ArgumentValue::Flag(_) => FlagConstraint.fill_placeholder(value, &placeholder.args),
}?;

let mut bytes = original
Expand All @@ -35,7 +34,7 @@ pub(super) fn fill_first_placeholder(original: &str, values: &HashMap<String, Ar
mod tests {
use rstest::rstest;

use std::{ops::Range, collections::HashMap};
use std::collections::HashMap;

use crate::{map, domain::ArgumentValue};

Expand All @@ -55,14 +54,14 @@ mod tests {
fn can_fill_placeholder(placeholder: &str, expected: &str, value: ArgumentValue, placeholder_arg: Option<HashMap<&str, &str>>) {
let value_map = map!("fill".to_string() => value);

let blanket_start = (placeholder.find('_').unwrap());
let blanket_start = placeholder.find('_').unwrap();

let filled = fill_first_placeholder(placeholder, &value_map, &Placeholder {
range: blanket_start..(blanket_start + 4),
arg_name: "fill".to_string(),
prefix: "".to_string(),
args: placeholder_arg.unwrap_or_default().iter().map(|(k, v)| (k.to_string(), v.to_string())).collect()
});
assert_eq!(filled.map(|(s, r)| s), Ok(expected.to_string()))
assert_eq!(filled.map(|(s, _)| s), Ok(expected.to_string()))
}
}
1 change: 0 additions & 1 deletion src/placeholder/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use std::{collections::HashMap, convert::TryInto};
use once_cell::sync::Lazy;
use regex::Regex;

use crate::domain::ArgumentValue;
use crate::helper::range_shift::RangeShift;

use super::{Placeholder, PlaceholderParseError};
Expand Down
2 changes: 1 addition & 1 deletion src/runner/tmpfile.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{fs::File, io::{Error, Write}, env, path::MAIN_SEPARATOR};
use std::{fs::File, io::Write, env, path::MAIN_SEPARATOR};

use crate::util::get_random_string;

Expand Down

0 comments on commit f9db6c0

Please # to comment.