Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VALVE undo/redo #64

Merged
merged 7 commits into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ rev = "f46fbd5450505644ed9970cef1ae14164699981f"

[dependencies.ontodev_valve]
git = "https://github.com/ontodev/valve.rs"
rev = "074b99254e4cc956c84cf7b68bff26cae57f0d16"
rev = "25dd32d0bd22a539043515e35c5b9b5803e3baf6"

[dependencies.ontodev_sqlrest]
git = "https://github.com/ontodev/sqlrest.rs"
Expand Down
7 changes: 4 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ usage:

.PHONY: deps
deps:
sudo apt-get update
sudo apt-get install -y rustc cargo
sudo apt-get install -y python3-pip
sudo pip install tesh
Expand Down Expand Up @@ -90,7 +91,7 @@ TODAY := $(shell date +%Y-%m-%d)
ARCH := x86_64-unknown-linux-musl
TARGET := build/nanobot-$(ARCH)

target/$(ARCH)/release/nanobot: src
target/$(ARCH)/release/nanobot: src/*.rs
docker pull clux/muslrust:stable
docker run \
-v cargo-cache:/root/.cargo/registry \
Expand All @@ -99,7 +100,7 @@ target/$(ARCH)/release/nanobot: src
cargo build --release

.PHONY: musl
musl: target/$(ARCH)/release/nanobot src/ | build/
musl: target/$(ARCH)/release/nanobot | build/

.PHONY: upload
upload: target/$(ARCH)/release/nanobot | build/
Expand All @@ -113,4 +114,4 @@ release: target/$(ARCH)/release/nanobot | build/
--title "$(TODAY) Alpha Release" \
--generate-notes \
v$(TODAY) $(TARGET)
echo "Please publish GitHub release v$(TODAY)"
@echo "Please publish GitHub release v$(TODAY)"
26 changes: 21 additions & 5 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ pub struct Config {
pub logging_level: LoggingLevel,
pub connection: String,
pub pool: Option<AnyPool>,
pub valve_path: String,
pub valve: Option<ValveConfig>,
pub valve_path: String,
pub valve_create_only: bool,
pub valve_initial_load: bool,
pub asset_path: Option<String>,
pub template_path: Option<String>,
pub actions: IndexMap<String, ActionConfig>,
Expand Down Expand Up @@ -157,14 +159,16 @@ impl Config {
.database
.unwrap_or_default()
.connection
.unwrap_or(".nanobot,db".into()),
.unwrap_or(".nanobot.db".into()),
pool: None,
valve: None,
valve_path: user
.valve
.unwrap_or_default()
.path
.unwrap_or("src/schema/table.tsv".into()),
valve: None,
valve_create_only: false,
valve_initial_load: false,
asset_path: {
match user.assets.unwrap_or_default().path {
Some(p) => {
Expand Down Expand Up @@ -248,12 +252,14 @@ impl Config {
}

pub async fn load_valve_config(&mut self) -> Result<&mut Config, String> {
// TODO: Make the path configurable:
let verbose = false;
let initial_load = false;
match valve(
&self.valve_path,
&self.connection,
&ValveCommand::Config,
false,
verbose,
initial_load,
"table",
)
.await
Expand Down Expand Up @@ -286,6 +292,16 @@ impl Config {
self.connection = connection.into();
self
}

pub fn create_only(&mut self, value: bool) -> &mut Config {
self.valve_create_only = value;
self
}

pub fn initial_load(&mut self, value: bool) -> &mut Config {
self.valve_initial_load = value;
self
}
}

impl fmt::Display for Config {
Expand Down
Loading