13 Commits

Author SHA1 Message Date
adf2722668 Add check the execute of mysql and postgres dump 2020-08-21 15:17:23 +07:00
49808ae529 Updated code ideaz 2020-08-20 21:46:57 +07:00
024fd2ac9d Add api for travis 2020-08-20 21:39:58 +07:00
309446608d Updated repo name 2020-08-20 21:32:14 +07:00
2631987a07 Add travis and updated 2020-08-20 21:21:19 +07:00
0aa36825b0 Add travis but not yet 2020-08-20 20:59:34 +07:00
Sambo Chea
cf5ca2073e Create rust.yml 2020-08-20 20:57:30 +07:00
453649b1ce Update the categories 2020-08-20 20:44:30 +07:00
398e9bf71d Remove unused 2020-08-20 20:42:28 +07:00
242c13099b Updated version 2020-08-20 20:42:12 +07:00
e77020a15b Updated the meta data more 2020-08-20 20:39:08 +07:00
645cd73d44 Updated cargo meta data 2020-08-20 20:36:47 +07:00
6f670a6f8c Updated readme 2020-08-20 20:33:04 +07:00
11 changed files with 265 additions and 5 deletions

17
.github/workflows/rust.yml vendored Normal file
View File

@@ -0,0 +1,17 @@
on: [push]
name: CSRS - CI
jobs:
build_and_test:
name: csrs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
- uses: actions-rs/cargo@v1
with:
command: build
args: --release --all-features

40
.idea/codeStyles/Project.xml generated Normal file
View File

@@ -0,0 +1,40 @@
<component name="ProjectCodeStyleConfiguration">
<code_scheme name="Project" version="173">
<JetCodeStyleSettings>
<option name="PACKAGES_TO_USE_STAR_IMPORTS">
<value>
<package name="kotlinx.android.synthetic" alias="false" withSubpackages="true" />
</value>
</option>
<option name="PACKAGES_IMPORT_LAYOUT">
<value>
<package name="" alias="false" withSubpackages="true" />
<package name="java" alias="false" withSubpackages="true" />
<package name="javax" alias="false" withSubpackages="true" />
<package name="kotlin" alias="false" withSubpackages="true" />
<package name="" alias="true" withSubpackages="true" />
</value>
</option>
<option name="NAME_COUNT_TO_USE_STAR_IMPORT" value="2147483647" />
<option name="NAME_COUNT_TO_USE_STAR_IMPORT_FOR_MEMBERS" value="2147483647" />
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
</JetCodeStyleSettings>
<codeStyleSettings language="XML">
<indentOptions>
<option name="CONTINUATION_INDENT_SIZE" value="4" />
</indentOptions>
</codeStyleSettings>
<codeStyleSettings language="kotlin">
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
<option name="LINE_COMMENT_AT_FIRST_COLUMN" value="false" />
<option name="LINE_COMMENT_ADD_SPACE" value="true" />
<option name="KEEP_BLANK_LINES_IN_DECLARATIONS" value="1" />
<option name="KEEP_BLANK_LINES_IN_CODE" value="1" />
<option name="KEEP_BLANK_LINES_BEFORE_RBRACE" value="0" />
<option name="ALIGN_MULTILINE_PARAMETERS" value="false" />
<indentOptions>
<option name="CONTINUATION_INDENT_SIZE" value="4" />
</indentOptions>
</codeStyleSettings>
</code_scheme>
</component>

5
.idea/codeStyles/codeStyleConfig.xml generated Normal file
View File

@@ -0,0 +1,5 @@
<component name="ProjectCodeStyleConfiguration">
<state>
<option name="PREFERRED_PROJECT_CODE_STYLE" value="ktlint" />
</state>
</component>

12
.idea/csrs.iml generated Normal file
View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

View File

@@ -0,0 +1,50 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="ArrayInDataClass" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
<inspection_tool class="CanBeParameter" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="DuplicatedCode" enabled="true" level="WARNING" enabled_by_default="true">
<Languages>
<language minSize="57" name="Kotlin" />
</Languages>
</inspection_tool>
<inspection_tool class="JavaDoc" enabled="true" level="WARNING" enabled_by_default="true">
<option name="TOP_LEVEL_CLASS_OPTIONS">
<value>
<option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" />
<option name="REQUIRED_TAGS" value="" />
</value>
</option>
<option name="INNER_CLASS_OPTIONS">
<value>
<option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" />
<option name="REQUIRED_TAGS" value="" />
</value>
</option>
<option name="METHOD_OPTIONS">
<value>
<option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" />
<option name="REQUIRED_TAGS" value="@return@param@throws or @exception" />
</value>
</option>
<option name="FIELD_OPTIONS">
<value>
<option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" />
<option name="REQUIRED_TAGS" value="" />
</value>
</option>
<option name="IGNORE_DEPRECATED" value="false" />
<option name="IGNORE_JAVADOC_PERIOD" value="true" />
<option name="IGNORE_DUPLICATED_THROWS" value="false" />
<option name="IGNORE_POINT_TO_ITSELF" value="false" />
<option name="myAdditionalJavadocTags" value="date,email" />
</inspection_tool>
<inspection_tool class="JpaAttributeTypeInspection" enabled="false" level="ERROR" enabled_by_default="false" />
<inspection_tool class="JpaDataSourceORMInspection" enabled="false" level="ERROR" enabled_by_default="false" />
<inspection_tool class="KotlinUnusedImport" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="MVCPathVariableInspection" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="RedundantSemicolon" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="SqlDialectInspection" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="SqlNoDataSourceInspection" enabled="false" level="WARNING" enabled_by_default="false" />
</profile>
</component>

8
.idea/modules.xml generated Normal file
View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/csrs.iml" filepath="$PROJECT_DIR$/.idea/csrs.iml" />
</modules>
</component>
</project>

6
.idea/vcs.xml generated Normal file
View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

67
.travis.yml Normal file
View File

@@ -0,0 +1,67 @@
os:
- linux
language: rust
rust:
- stable
cache:
- apt
matrix:
include:
- env:
- NAME=csrs
- TARGET=arm-unknown-linux-gnueabihf
- LINKER=arm-linux-gnueabihf-gcc
- PACKAGE=$NAME-rpi2.tar.gz
addons:
apt:
packages: &1
- gcc-arm-linux-gnueabihf
- libc6-armhf-cross
- libc6-dev-armhf-cross
- env:
- NAME=csrs
- TARGET=armv7-unknown-linux-gnueabihf
- LINKER=arm-linux-gnueabihf-gcc
- PACKAGE=$NAME-rpi3.tar.gz
addons:
apt:
packages: *1
- env:
- NAME=csrs
- TARGET=i686-unknown-linux-gnu
- PACKAGE=$NAME-i686.tar.gz
addons:
apt:
packages:
- gcc-multilib
- env:
- NAME=csrs
- TARGET=x86_64-unknown-linux-gnu
- PACKAGE=$NAME-x86_64.tar.gz
install:
- export PATH="$PATH:$HOME/.cargo/bin"
- rustup target add $TARGET || true
- |
if [ -n "$LINKER" ]; then
mkdir -p ~/.cargo
echo >> ~/.cargo/config
echo "[target.$TARGET]" >> ~/.cargo/config
echo "linker = \"$LINKER\"" >> ~/.cargo/config
fi
script:
- |
if [ $TARGET = "x86_64-unknown-linux-gnu" ]; then
cargo test
fi
- cargo build --target $TARGET --verbose --release
before_deploy:
- tar -czf $PACKAGE -C target/$TARGET/release/ $NAME
deploy:
provider: releases
api_key:
secure: s+12tcnhr8MxZzawRXpIunuq1CPdlnSTjHiwHcrSinTVn2qJLVrbn0I8mXji2J7hW84MuGF8Y/yp7ikKjSF4nm8CQPBTZdWFy7b7wjRknGDr9gZwJFbelEjMBSVh4WAXYOywYR3yA4i2jsFpCLJ3xIa2LFIFBYlYajCNnKOqrNquDDJ1LwKc4wG0ZUSnVpElL15TyoFSJOuRRIyDLn9WDt3NiJlgv4cnXPSgCRMpftWQGtQbZBmU+wTl2+83jZ54LzIw1XrZ2k1dGdjdcGECQ1bsHnVHg0xce7EcslKeExI/kHqceH7V2YL116luuRZlsALZQw1Pj8A49ydKMZiXVLL1QVvM6+qBDuKobBlI0rhx2BJhO936K/6WuVGgrqLSrYOC3oWbRXEIIvc0IH9SFQw3N638eghnRNRORty+Hww3qVorzfvuoHkSjO1mLqSyf0dgZ3rdzm4MijxUZgORwBIENCXwNThwJ2v2fodIq+hk855ZzXQfRWPloriDFjiaDXgt8cHOWq5SF9rAK9hEpqoPS4WlmXVVcAVhC/TC4edjuN1GRIu5aImRm9yFgg573ABLhHitQxB/VutRdVh5beq2cAHYBSIvS2zDm0CwslIdmTIuD/QFhXI58bVgbrEt+Cm4lTzVFDmPDAi1CnKY8asOT5DB+DM6l61dcDC+d7o=
file: "${PACKAGE}"
skip_cleanup: true
on:
tags: true
repo: CUBETIQ/csrs

View File

@@ -1,11 +1,16 @@
[package] [package]
name = "csrs" name = "csrs"
version = "0.1.0" version = "0.1.2-dev"
authors = ["Sambo Chea <sombochea@cubetiqs.com>"] authors = ["Sambo Chea <sombochea@cubetiqs.com>"]
edition = "2018" edition = "2018"
description = "CUBETIQ Syncer for database tools and internal tool for the team in the company."
license = "MIT"
repository = "https://github.com/CUBETIQ/csrs.git"
keywords = ["rust-cli", "cubetiq-cli", "tools", "clap"]
categories = ["command-line-interface", "command-line-utilities"]
readme = "README.md"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
structopt = "0.3.13"
clap = "2.33.3" clap = "2.33.3"

View File

@@ -1,6 +1,11 @@
<code>CUBETIQ Syncer for Database Tools</code> <div align="center">
<h2><code>CUBETIQ Syncer for Database Tools</code></h2>
</div>
<div align="center">
<h4><code>Roadmap</code></h4>
</div>
<code>Roadmap</code>
- [ ] Implement the command line app (CLI) - [ ] Implement the command line app (CLI)
- [ ] Make the cli call the api for sync the data - [ ] Make the cli call the api for sync the data
- [ ] Encrypt the data within password - [ ] Encrypt the data within password

View File

@@ -1,4 +1,8 @@
use clap::{Arg, App}; use std::io::ErrorKind;
use std::path::Path;
use std::process::Command;
use clap::{App, Arg};
fn main() { fn main() {
let matches = App::new("CUBETIQ Syncer") let matches = App::new("CUBETIQ Syncer")
@@ -31,4 +35,45 @@ fn main() {
println!("Your app id is: {}", s); println!("Your app id is: {}", s);
} }
} }
let _b = check_mysqldump();
println!("MySQL Dump is {}", _b);
let _b1 = check_pg_dump();
println!("Postgres Dump is {}", _b1);
}
fn check_is_windows() -> bool {
return cfg!(windows)
}
fn check_mysqldump() -> bool {
let mut mysqldump_file = "mysqldump".to_owned();
if check_is_windows() {
mysqldump_file.push_str(".exe");
}
return match Command::new(mysqldump_file).spawn() {
Ok(_) => true,
Err(e) => {
if let _not_found = e.kind() {
println!("`mysqldump` not found to execute, please add it into PATH!");
}
false
},
}
}
fn check_pg_dump() -> bool {
let mut pg_dump_filename = "pg_dump".to_owned();
if check_is_windows() {
pg_dump_filename.push_str(".exe");
}
return match Command::new(pg_dump_filename).spawn() {
Ok(_) => true,
Err(e) => {
if let _not_found = e.kind() {
println!("`pg_dump` not found to execute, please add it into PATH!");
}
false
},
}
} }