chore: merge cli with core

This commit is contained in:
Dmitriy Pleshevskiy 2021-02-05 01:37:25 +03:00
parent 5833e8802c
commit e8cce2fca5
8 changed files with 7 additions and 24 deletions

View File

@ -1,5 +1,4 @@
[workspace]
members = [
"migra-core",
"migra-cli"
]

View File

@ -10,8 +10,8 @@ name = "migra"
path = "src/main.rs"
[dependencies]
migra-core = { path = '../migra-core' }
structopt = "0.3"
serde = { version = "1.0", features = ["derive"] }
toml = "0.5"
chrono = "0.4.19"
postgres = "0.19.0"

View File

@ -1,4 +1,4 @@
use migra_core::path::PathBuilder;
use crate::path::PathBuilder;
use serde::{Deserialize, Serialize};
use std::path::{Path, PathBuf};
use std::{fs, io};

View File

@ -1,12 +1,14 @@
#![deny(clippy::all)]
mod config;
mod database;
mod opts;
mod path;
use chrono::Local;
use config::Config;
use migra_core::path::PathBuilder;
use opts::{AppOpt, ApplyCommandOpt, Command, MakeCommandOpt, StructOpt};
use path::PathBuilder;
use std::fs;
fn main() -> Result<(), Box<dyn std::error::Error>> {
@ -19,7 +21,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
Command::Apply(ApplyCommandOpt { file_name }) => {
let config = Config::read(opt.config)?;
let mut client = migra_core::database::connect(&config.database.connection)?;
let mut client = database::connect(&config.database.connection)?;
let file_path = PathBuilder::from(config.directory_path())
.append(file_name)
@ -28,7 +30,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
let content = fs::read_to_string(file_path)?;
match migra_core::database::apply_sql(&mut client, &content) {
match database::apply_sql(&mut client, &content) {
Ok(_) => {
println!("File was applied successfully")
}

View File

@ -15,12 +15,6 @@ impl<P: AsRef<Path>> From<P> for PathBuilder {
}
impl PathBuilder {
pub fn new<P: AsRef<Path>>() -> Self {
PathBuilder {
buf: PathBuf::new(),
}
}
pub fn append<P: AsRef<Path>>(&mut self, path: P) -> &mut Self {
self.buf.push(path);
self

View File

@ -1,8 +0,0 @@
[package]
name = "migra-core"
version = "0.1.0"
authors = ["Dmitriy Pleshevskiy <dmitriy@ideascup.me>"]
edition = "2018"
[dependencies]
postgres = "0.19.0"

View File

@ -1,4 +0,0 @@
#![deny(clippy::all)]
pub mod database;
pub mod path;