The blackbean is a command tool for elasticsearch operations by using cobra.

Related tags

blackbean
Overview

Go 1.16 codecov CI Workflow Go Report Card

blackbean

The blackbean is a command tool for elasticsearch operations by using cobra. Besides, blackbean is the name of my lovely French bulldog.

image

Configuration

Define your config file firstly, and specify current as one of your cluster.

cluster:
  default:
    url: https://a.es.com:9200
    username: Noah
    password: abc
  backup:
    url: https://b.es.com:9200
    username: Noah
    password: abc
current: default

Shell completion

> ~/.bashrc ">
[[email protected] ~]# echo "source <(blackbean completion bash)" >> ~/.bashrc
[[email protected] ~]# blackbean [tab][tab]
apply       completion  current     get         help        repo        snapshot    use
[[email protected] ~]# blackbean get [tab][tab]
allocations   cachemem      health        largeindices  nodes         segmem        threadpoo

Command

[[email protected] ~]# blackbean [tab][tab]
apply       completion  current     get         help        repo        snapshot    use
[[email protected] ~]# blackbean
blackbean command provides a set of commands to talk with es via cli.
Besides, blackbean is the name of my favorite french bulldog.

Usage:
  blackbean [command]

Available Commands:
  apply       apply cluster settings.
  completion  Generate completion script
  current     show current cluster context
  get         get allocation/nodes/health/nodes/threadpool/cache memory/segments memory/large indices.
  help        Help about any command
  repo        repo operations
  snapshot    snapshot operations
  use         change current cluster context

Flags:
      --config string   config file (default is $HOME/.blackbean.yaml)
  -h, --help            help for blackbean
  -t, --toggle          Help message for toggle

Use "blackbean [command] --help" for more information about a command.

Use

[[email protected] ~]# blackbean current
current using cluster: qa
[[email protected] ~]# blackbean use [tab][tab]
prod  qa
[[email protected] ~]# blackbean use qa
change to cluster: qa

Get info

[[email protected] ~]# blackbean get health 
[200 OK] epoch      timestamp cluster       status node.total node.data shards  pri relo init unassign pending_tasks max_task_wait_time active_shards_percent
1624371902 14:25:02  black-cluster green          12         9   9304 4652    0    0        0             0                  -                100.0%

Put Settings

[[email protected] ~]# blackbean apply settings -e
null       primaries
[[email protected] ~]# blackbean apply settings -h
apply cluster settings ... wordless

Usage:
  blackbean apply [resource] [flags]

Flags:
  -e, --allocation_enable string                   to set allocation enable value, primaries or null
  -f, --breaker_fielddata string                   to set breaker_fielddata value, such as 60%
  -r, --breaker_request string                     to set breaker_request value, such as 60%
  -t, --breaker_total string                       to set breaker_total value, such as 60%
  -a, --cluster_concurrent_rebalanced string       to set cluster_concurrent_rebalanced value, such as 10
  -h, --help                                       help for apply
  -b, --max_bytes_per_sec string                   to set indices recovery max_bytes_per_sec, default 40
  -m, --max_compilations_rate string               to set max_compilations_rate value, such as 75/5m
  -s, --max_shards_per_node string                 to set max_shards_per_node value, such as 1000
  -n, --node_concurrent_recoveries string          to set node_concurrent_recoveries value, such as 10
  -i, --node_initial_primaries_recoveries string   to set node_initial_primaries_recoveries value, such as 10
  -w, --watermark_high string                      to set watermark_high value, such as 85%
  -l, --watermark_low string                       to set watermark_low value, such as 90%

Global Flags:
  -c, --cluster string   to specify a es cluster (default "default")
      --config string    config file (default is $HOME/.blackbean.yaml)

Repo

[[email protected] ~]# blackbean repo
repo operations ... wordless

Usage:
  blackbean repo [command]

Available Commands:
  create      create specific snapshots
  delete      delete specific snapshots
  get         get specific repository

Flags:
  -h, --help   help for repo

Global Flags:
      --config string   config file (default is $HOME/.blackbean.yaml)

Use "blackbean repo [command] --help" for more information about a command.

Snapshot

[[email protected] ~]# blackbean snapshot
snapshot operations ... wordless

Usage:
  blackbean snapshot [command]

Available Commands:
  create      create specific snapshots
  delete      delete specific snapshots
  get         get specific snapshots
  restore     get specific index to restore

Flags:
  -h, --help   help for snapshot

Global Flags:
      --config string   config file (default is $HOME/.blackbean.yaml)

Use "blackbean snapshot [command] --help" for more information about a command.

Index Search

[[email protected] ~]# blackbean index
index operations ... wordless

Usage:
  blackbean index [command]

Available Commands:
  get         get index from cluster
  search      search index from cluster

Flags:
  -h, --help   help for index

Global Flags:
      --config string   config file (default is $HOME/.blackbean.yaml)

Use "blackbean index [command] --help" for more information about a command.
[[email protected] ~]# blackbean index search test-* -f query.json
[200 OK] {
  "took" : 172,
  "timed_out" : false,
  "_shards" : {
    "total" : 5,
    "successful" : 5,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 16600,
      "relation" : "eq"
    },
    "max_score" : 1.0,
    "hits" : [
      {
  ...
[[email protected] ~]# blackbean index search test-* -f query.yaml
[200 OK] {
  "took" : 172,
  "timed_out" : false,
  ...
[[email protected] ~]# blackbean index search test-* -d '{"query":{"match_all":{}}}'
[200 OK] {
  "took" : 172,
  "timed_out" : false,
  ...

Index Get

[[email protected] ~]# blackbean index get test-2021.06
[200 OK] {
  "test-2021.06" : {
    "aliases" : { },
    "mappings" : {
      "dynamic_templates" : [
        {
          "strings" : {
            "match_mapping_type" : "string",
            "mapping" : {
              "type" : "keyword"
            }
    ...

Contact Me

Any advice is welcome! Please email to [email protected]

Issues
Build an interactive CLI application with Go, Cobra and promptui. Video tutorial available on the Div Rhino YouTube channel.

Build an interactive CLI app with Go, Cobra and promptui Text tutorial: https://divrhino.com/articles/build-interactive-cli-app-with-go-cobra-promptui

Div Rhino Dev 4 Sep 3, 2021
A versatile library for building CLI applications in Go

mow.cli Package cli provides a framework to build command line applications in Go with most of the burden of arguments parsing and validation placed o

Jawher Moussa 748 Sep 5, 2021
Handy little CLI for interacting with OCI data

oci-tool Handy little CLI for interacting with OCI data Installation go get github.com/csweichel/oci-tool I use Gitpod for developing this tool; you s

Christian Weichel 7 Aug 22, 2021
Generate flags by parsing structures

Flags based on structures. The sflags package uses structs, reflection and struct field tags to allow you specify command line options. It supports di

null 130 Aug 1, 2021
Kong is a command-line parser for Go

Kong is a command-line parser for Go Introduction Help Help as a user of a Kong application Defining help in Kong Command handling Switch on the comma

Alec Thomas 654 Sep 15, 2021
jt is a CLI tool for viewing and manipulating JIRA issues.

jt - jira-tool jt is a CLI tool for viewing and manipulating JIRA issues. One common example usage to transition an issue to a new status: jt "In Prog

Steve Coffman 7 Sep 2, 2021
Secure, private and feature-rich CLI password manager

Kure Kure is a free and open-source password manager for the command-line. This project aims to offer the most secure and private way of operating wit

Gastón Palomeque 107 Aug 26, 2021
Fully featured Go (golang) command line option parser with built-in auto-completion support.

go-getoptions Go option parser inspired on the flexibility of Perl’s GetOpt::Long. Table of Contents Quick overview Examples Simple script Program wit

David Gamba 38 Aug 29, 2021
Generate ANSI-/Ascii-art version images/Gifs in your terminal.

ANSI-Art NOTE: This toy project is not yet finished. ANSI-version Logo Block ANSI-version Logo ASCII-version Logo Support Platform You are kindly remi

Weiran Huang 8 Aug 24, 2021
A command-line tool and library for generating regular expressions from user-provided test cases

Table of Contents What does this tool do? Do I still need to learn to write regexes then? Current features How to install? 4.1 The command-line tool 4

Peter M. Stahl 4.3k Sep 15, 2021
git-xargs is a command-line tool (CLI) for making updates across multiple Github repositories with a single command.

Table of contents Introduction Reference Contributing Introduction Overview git-xargs is a command-line tool (CLI) for making updates across multiple

Gruntwork 474 Sep 13, 2021
Idiomatic Go input parsing with subcommands, positional values, and flags at any position. No required project or package layout and no external dependencies.

Sensible and fast command-line flag parsing with excellent support for subcommands and positional values. Flags can be at any position. Flaggy has no

Eric Greer 733 Sep 6, 2021
sg is the CLI tool that Sourcegraph developers can use to develop Sourcegraph.

sg is the CLI tool that Sourcegraph developers can use to develop Sourcegraph.

Sourcegraph 13 Sep 10, 2021
:cherry_blossom: A command-line fuzzy finder

fzf is a general-purpose command-line fuzzy finder. It's an interactive Unix filter for command-line that can be used with any list; files, command hi

Junegunn Choi 39k Sep 13, 2021
CONTRIBUTIONS ONLY: A Go (golang) command line and flag parser

CONTRIBUTIONS ONLY What does this mean? I do not have time to fix issues myself. The only way fixes or new features will be added is by people submitt

Alec Thomas 3.1k Sep 6, 2021
Interactive prompt for command-line applications

promptui Interactive prompt for command-line applications. We built Promptui because we wanted to make it easy and fun to explore cloud services with

Manifold 4.4k Sep 10, 2021
Simple time tracking CLI

⏰ timetrace timetrace is a simple CLI for tracking your working time. Installation Homebrew brew tap dominikbraun/timetrace brew install timetrace Do

Dominik Braun 443 Sep 8, 2021
CLI - A package for building command line app with go

Command line interface Screenshot Key features Lightweight and easy to use. Defines flag by tag, e.g. flag name(short or/and long), description, defau

王仕晋 601 Sep 5, 2021
Automatically sets up command line flags based on struct fields and tags.

Commandeer Commandeer sets up command line flags based on struct fields and tags. Do you... like to develop Go apps as libraries with tiny main packag

Matthew Jaffee 148 Jun 25, 2021