Skip to content

Commit

Permalink
Add cli package (#83)
Browse files Browse the repository at this point in the history
* Add cli package

* Delete metrics

* Delete comments
  • Loading branch information
mosuka authored May 8, 2020
1 parent 060455d commit b8c0a72
Show file tree
Hide file tree
Showing 118 changed files with 1,365 additions and 2,610 deletions.
56 changes: 40 additions & 16 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
[workspace]
members = [
"bayard-common",
"bayard-server",
"bayard-client",
"bayard-cli",
"bayard-rest",
"bayard",
]
11 changes: 11 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
BIN_DIR ?= $(CURDIR)/bin
DOCS_DIR ?= $(CURDIR)/docs
COMMON_VERSION ?= $(shell cargo metadata --no-deps --format-version=1 | jq -r '.packages[] | select(.name=="bayard-common") | .version')
SERVER_VERSION ?= $(shell cargo metadata --no-deps --format-version=1 | jq -r '.packages[] | select(.name=="bayard-server") | .version')
CLIENT_VERSION ?= $(shell cargo metadata --no-deps --format-version=1 | jq -r '.packages[] | select(.name=="bayard-client") | .version')
CLI_VERSION ?= $(shell cargo metadata --no-deps --format-version=1 | jq -r '.packages[] | select(.name=="bayard-cli") | .version')
REST_VERSION ?= $(shell cargo metadata --no-deps --format-version=1 | jq -r '.packages[] | select(.name=="bayard-rest") | .version')
VERSION ?= $(shell cargo metadata --no-deps --format-version=1 | jq -r '.packages[] | select(.name=="bayard") | .version')

Expand All @@ -18,6 +20,7 @@ build:
mkdir -p $(BIN_DIR)
cargo build --release
cp -p ./target/release/bayard $(BIN_DIR)
cp -p ./target/release/bayard-cli $(BIN_DIR)
cp -p ./target/release/bayard-rest $(BIN_DIR)

test:
Expand All @@ -28,6 +31,10 @@ tag:
git push origin v$(VERSION)

publish:
ifeq ($(shell cargo show --json bayard-common | jq -r '.versions[].num' | grep $(COMMON_VERSION)),)
(cd bayard-common && cargo package && cargo publish)
sleep 10
endif
ifeq ($(shell cargo show --json bayard-server | jq -r '.versions[].num' | grep $(SERVER_VERSION)),)
(cd bayard-server && cargo package && cargo publish)
sleep 10
Expand All @@ -36,6 +43,10 @@ ifeq ($(shell cargo show --json bayard-client | jq -r '.versions[].num' | grep $
(cd bayard-client && cargo package && cargo publish)
sleep 10
endif
ifeq ($(shell cargo show --json bayard-cli | jq -r '.versions[].num' | grep $(CLI_VERSION)),)
(cd bayard-cli && cargo package && cargo publish)
sleep 10
endif
ifeq ($(shell cargo show --json bayard-rest | jq -r '.versions[].num' | grep $(REST_VERSION)),)
(cd bayard-rest && cargo package && cargo publish)
sleep 10
Expand Down
24 changes: 24 additions & 0 deletions bayard-cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[package]
name = "bayard-cli"
version = "0.8.0"
authors = ["Minoru Osuka <[email protected]>"]
edition = "2018"
description = "Command line interface for Bayard."
documentation = "https://bayard-search.github.io/bayard/"
homepage = "https://github.com/bayard-search"
repository = "https://github.com/bayard-search/bayard/bayard-cli"
readme = "README.md"
keywords = ["full-text", "search", "index", "cli"]
categories = ["database"]
license = "MIT"

[[bin]]
name = "bayard-cli"
path = "src/main.rs"

[dependencies]
clap = "2.33.0"
serde_json = "1.0.51"

bayard-client = { version = "0.8.0", path = "../bayard-client" }
bayard-common = { version = "0.8.0", path = "../bayard-common" }
8 changes: 8 additions & 0 deletions bayard-cli/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Bayard

[![Join the chat at https://gitter.im/bayard-search/bayard](https://badges.gitter.im/bayard-search/bayard.svg)](https://gitter.im/bayard-search/bayard?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

Bayard is a full-text search and indexing server written in [Rust](https://www.rust-lang.org/) built on top of [Tantivy](https://github.com/tantivy-search/tantivy) that implements [Raft Consensus Algorithm](https://raft.github.io/) and [gRPC](https://grpc.io/).
Achieves consensus across all the nodes, ensures every change made to the system is made to a quorum of nodes.
Bayard makes easy for programmers to develop search applications with advanced features and high availability.
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@ use clap::ArgMatches;

use bayard_client::index::client::IndexClient;

use crate::log::set_logger;

pub fn run_bulk_delete_cli(matches: &ArgMatches) -> Result<(), std::io::Error> {
set_logger();

let server = matches.value_of("SERVER").unwrap();
let docs = matches.value_of("DOCS").unwrap();

Expand Down
4 changes: 0 additions & 4 deletions bayard/src/cli/bulk_set.rs → bayard-cli/src/cli/bulk_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@ use clap::ArgMatches;

use bayard_client::index::client::IndexClient;

use crate::log::set_logger;

pub fn run_bulk_set_cli(matches: &ArgMatches) -> Result<(), std::io::Error> {
set_logger();

let server = matches.value_of("SERVER").unwrap();
let docs = matches.value_of("DOCS").unwrap();

Expand Down
4 changes: 0 additions & 4 deletions bayard/src/cli/commit.rs → bayard-cli/src/cli/commit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@ use clap::ArgMatches;

use bayard_client::index::client::IndexClient;

use crate::log::set_logger;

pub fn run_commit_cli(matches: &ArgMatches) -> Result<(), std::io::Error> {
set_logger();

let server = matches.value_of("SERVER").unwrap();

let mut index_client = IndexClient::new(server);
Expand Down
4 changes: 0 additions & 4 deletions bayard/src/cli/delete.rs → bayard-cli/src/cli/delete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@ use clap::ArgMatches;

use bayard_client::index::client::IndexClient;

use crate::log::set_logger;

pub fn run_delete_cli(matches: &ArgMatches) -> Result<(), std::io::Error> {
set_logger();

let server = matches.value_of("SERVER").unwrap();
let id = matches.value_of("ID").unwrap();

Expand Down
4 changes: 0 additions & 4 deletions bayard/src/cli/get.rs → bayard-cli/src/cli/get.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@ use clap::ArgMatches;

use bayard_client::index::client::IndexClient;

use crate::log::set_logger;

pub fn run_get_cli(matches: &ArgMatches) -> Result<(), std::io::Error> {
set_logger();

let server = matches.value_of("SERVER").unwrap();
let id = matches.value_of("ID").unwrap();

Expand Down
4 changes: 0 additions & 4 deletions bayard/src/cli/leave.rs → bayard-cli/src/cli/leave.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@ use clap::ArgMatches;

use bayard_client::raft::client::RaftClient;

use crate::log::set_logger;

pub fn run_leave_cli(matches: &ArgMatches) -> Result<(), std::io::Error> {
set_logger();

let server = matches.value_of("SERVER").unwrap();
let id = matches.value_of("ID").unwrap().parse::<u64>().unwrap();

Expand Down
4 changes: 0 additions & 4 deletions bayard/src/cli/merge.rs → bayard-cli/src/cli/merge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@ use clap::ArgMatches;

use bayard_client::index::client::IndexClient;

use crate::log::set_logger;

pub fn run_merge_cli(matches: &ArgMatches) -> Result<(), std::io::Error> {
set_logger();

let server = matches.value_of("SERVER").unwrap();

let mut index_client = IndexClient::new(server);
Expand Down
2 changes: 0 additions & 2 deletions bayard/src/cli/mod.rs → bayard-cli/src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@ pub mod delete;
pub mod get;
pub mod leave;
pub mod merge;
pub mod metrics;
pub mod rollback;
pub mod root;
pub mod schema;
pub mod search;
pub mod set;
pub mod start;
pub mod status;
4 changes: 0 additions & 4 deletions bayard/src/cli/rollback.rs → bayard-cli/src/cli/rollback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@ use clap::ArgMatches;

use bayard_client::index::client::IndexClient;

use crate::log::set_logger;

pub fn run_rollback_cli(matches: &ArgMatches) -> Result<(), std::io::Error> {
set_logger();

let server = matches.value_of("SERVER").unwrap();

let mut index_client = IndexClient::new(server);
Expand Down
Loading

0 comments on commit b8c0a72

Please sign in to comment.