fscli

package module
v0.15.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 27, 2026 License: MIT Imports: 23 Imported by: 0

README

fscli

A cli tool for firestore

Demo

fscli-demo

Installation

brew install maruware/tap/fscli

or download binary from Releases

or

go install github.com/maruware/fscli/cmd/fscli@latest

Prepare

$ gcloud auth application-default login

Usage

$ fscli --project-id my-project
Flag Description
--project-id Firebase project ID (required)
--out-mode Output format: table (default) or json
Quick Examples
QUERY users
QUERY users WHERE age = 20
QUERY users SELECT name WHERE age >= 20 ORDER BY name ASC LIMIT 10
GET users/ewpSGf5URC1L1vPENbxh
COUNT users WHERE name = "takashi"

Documentation

  • OperationsQUERY, GET, COUNT, collection paths
  • WHERE Filters — Operators (=, !=, >, <, IN, ARRAY_CONTAINS, ...), value types, TIMESTAMP(), __id__
  • ClausesSELECT, ORDER BY, LIMIT
  • Meta Commands\d, \pager
  • Output — Table / JSON output modes, non-interactive mode
JSON mode

The --out-mode json flag produces a single, valid JSON object (for GET) or an array of objects (for QUERY), making it easy to parse with tools like jq.

GET command output:

{
  "id": "documentId",
  "data": { "field": "value" }
}

QUERY command output:

[
  { "id": "doc1", "data": { "field": "value" } },
  { "id": "doc2", "data": { "field": "value" } }
]

Documentation

Index

Constants

View Source
const (
	VENDOR_NAME  = "maruware"
	APP_NAME     = "fscli"
	HISTORY_FILE = "history"
)
View Source
const (
	EOF     = "EOF"
	ILLEGAL = "ILLEGAL"

	GET              = "GET"
	QUERY            = "QUERY"
	COUNT            = "COUNT"
	SELECT           = "SELECT"
	COLLECTION_GROUP = "COLLECTION_GROUP"

	WHERE              = "WHERE"
	EQ                 = "="
	NOT_EQ             = "!="
	GT                 = ">"
	GTE                = ">="
	LT                 = "<"
	LTE                = "<="
	IN                 = "IN"
	ARRAY_CONTAINS     = "ARRAY_CONTAINS"
	ARRAY_CONTAINS_ANY = "ARRAY_CONTAINS_ANY"
	ORDER              = "ORDER"
	BY                 = "BY"

	ASC  = "ASC"
	DESC = "DESC"

	IDENT  = "IDENT"
	STRING = "STRING"
	INT    = "INT"
	FLOAT  = "FLOAT"

	AND = "AND"

	LIMIT = "LIMIT"

	LBRACKET = "["
	RBRACKET = "]"
	LPAREN   = "("
	RPAREN   = ")"
	COMMA    = ","

	F_TIMESTAMP = "TIMESTAMP"

	LIST_COLLECTIONS = "LIST_COLLECTIONS"
	PAGER            = "PAGER"
)
View Source
const FieldDocumentID = "__id__"
View Source
const LongLine = "--------------------------------------------------------------------------"
View Source
const PAGE_SIZE = 100

Variables

View Source
var ErrInvalidCollection = errors.New("invalid collection")

Functions

This section is empty.

Types

type ArrayFilter added in v0.2.0

type ArrayFilter struct {
	BaseFilter
	// contains filtered or unexported fields
}

func NewArrayFilter added in v0.2.0

func NewArrayFilter(field string, operator Operator, value []any) *ArrayFilter

func (*ArrayFilter) Value added in v0.2.0

func (f *ArrayFilter) Value() any

type BaseFilter

type BaseFilter struct {
	// contains filtered or unexported fields
}

func (*BaseFilter) FieldName

func (f *BaseFilter) FieldName() string

func (*BaseFilter) Operator

func (f *BaseFilter) Operator() Operator

type BaseMetacommand added in v0.7.0

type BaseMetacommand struct {
}

func (*BaseMetacommand) Type added in v0.7.0

func (m *BaseMetacommand) Type() string

type BaseOperation added in v0.7.0

type BaseOperation struct {
}

func (*BaseOperation) Type added in v0.7.0

func (op *BaseOperation) Type() string

type Completer added in v0.5.4

type Completer struct {
	// contains filtered or unexported fields
}

func NewCompleter added in v0.5.4

func NewCompleter(l *Lexer, findCollections func(baseDoc string) ([]string, error)) *Completer

func (*Completer) Parse added in v0.5.4

func (c *Completer) Parse() ([]prompt.Suggest, error)

type CountOperation added in v0.8.0

type CountOperation struct {
	BaseOperation
	// contains filtered or unexported fields
}

func NewCollectionGroupCountOperation added in v0.15.0

func NewCollectionGroupCountOperation(collectionGroup string, filters []Filter) *CountOperation

func NewCountOperation added in v0.8.0

func NewCountOperation(collection string, filters []Filter) *CountOperation

func (*CountOperation) Collection added in v0.8.0

func (op *CountOperation) Collection() string

func (*CountOperation) IsCollectionGroup added in v0.15.0

func (op *CountOperation) IsCollectionGroup() bool

func (*CountOperation) OperationType added in v0.8.0

func (op *CountOperation) OperationType() OperationType

type Executor

type Executor struct {
	// contains filtered or unexported fields
}

func NewExecutor

func NewExecutor(ctx context.Context, fs *firestore.Client) *Executor

func (*Executor) ExecuteCount added in v0.8.0

func (exe *Executor) ExecuteCount(ctx context.Context, op *CountOperation) (int64, error)

func (*Executor) ExecuteGet added in v0.3.0

func (exe *Executor) ExecuteGet(ctx context.Context, op *GetOperation) (*firestore.DocumentSnapshot, error)

func (*Executor) ExecuteListCollections added in v0.7.0

func (exe *Executor) ExecuteListCollections(ctx context.Context, cmd *MetacommandListCollections) ([]string, error)

func (*Executor) ExecuteQuery

func (exe *Executor) ExecuteQuery(ctx context.Context, op *QueryOperation) ([]*firestore.DocumentSnapshot, error)

type Filter

type Filter interface {
	FieldName() string
	Operator() Operator
	Value() any
}

type FloatFilter

type FloatFilter struct {
	BaseFilter
	// contains filtered or unexported fields
}

func NewFloatFilter

func NewFloatFilter(field string, operator Operator, value float64) *FloatFilter

func (*FloatFilter) Value

func (f *FloatFilter) Value() any

type GetOperation added in v0.3.0

type GetOperation struct {
	BaseOperation
	// contains filtered or unexported fields
}

func NewGetOperation added in v0.3.0

func NewGetOperation(collection string, docId string, selects []string) *GetOperation

func (*GetOperation) Collection added in v0.3.0

func (op *GetOperation) Collection() string

func (*GetOperation) DocId added in v0.3.0

func (op *GetOperation) DocId() string

func (*GetOperation) OperationType added in v0.3.0

func (op *GetOperation) OperationType() OperationType

func (*GetOperation) Selects added in v0.13.0

func (op *GetOperation) Selects() []string

type IntFilter

type IntFilter struct {
	BaseFilter
	// contains filtered or unexported fields
}

func NewIntFilter

func NewIntFilter(field string, operator Operator, value int) *IntFilter

func (*IntFilter) Value

func (f *IntFilter) Value() any

type Lexer

type Lexer struct {
	// contains filtered or unexported fields
}

func NewLexer

func NewLexer(input string) *Lexer

func (*Lexer) NextToken

func (l *Lexer) NextToken() Token

type Metacommand added in v0.7.0

type Metacommand interface {
	Type() string
	MetacommandType() string
}

type MetacommandListCollections added in v0.7.0

type MetacommandListCollections struct {
	BaseMetacommand
	// contains filtered or unexported fields
}

func (*MetacommandListCollections) MetacommandType added in v0.7.0

func (m *MetacommandListCollections) MetacommandType() string

type MetacommandPager added in v0.7.0

type MetacommandPager struct {
	BaseMetacommand
	// contains filtered or unexported fields
}

func (*MetacommandPager) MetacommandType added in v0.7.0

func (m *MetacommandPager) MetacommandType() string

type Operation

type Operation interface {
	Type() string
	OperationType() OperationType
	Collection() string
}

type OperationType added in v0.3.0

type OperationType string
const (
	OPERATION_TYPE_QUERY OperationType = "QUERY"
	OPERATION_TYPE_GET   OperationType = "GET"
	OPERATION_TYPE_COUNT OperationType = "COUNT"
)

type Operator added in v0.2.0

type Operator string
const (
	OPERATOR_EQ                 Operator = "=="
	OPERATOR_NOT_EQ             Operator = "!="
	OPERATOR_GT                 Operator = ">"
	OPERATOR_GTE                Operator = ">="
	OPERATOR_LT                 Operator = "<"
	OPERATOR_LTE                Operator = "<="
	OPERATOR_IN                 Operator = "in"
	OPERATOR_ARRAY_CONTAINS     Operator = "array-contains"
	OPERATOR_ARRAY_CONTAINS_ANY Operator = "array-contains-any"
)

type OrderBy added in v0.5.2

type OrderBy struct {
	// contains filtered or unexported fields
}

type OutputMode added in v0.4.0

type OutputMode string
const (
	OutputModeJSON  OutputMode = "json"
	OutputModeTable OutputMode = "table"
)

type ParseResult added in v0.7.0

type ParseResult interface {
	Type() string
}

type Parser

type Parser struct {
	// contains filtered or unexported fields
}

func NewParser

func NewParser(l *Lexer) *Parser

func (*Parser) Errors

func (p *Parser) Errors() []string

func (*Parser) Parse

func (p *Parser) Parse() (ParseResult, error)

type QueryOperation

type QueryOperation struct {
	BaseOperation
	// contains filtered or unexported fields
}

func NewCollectionGroupQueryOperation added in v0.15.0

func NewCollectionGroupQueryOperation(collectionGroup string, selects []string, filters []Filter, orderBys []OrderBy, limit int) *QueryOperation

func NewQueryOperation

func NewQueryOperation(collection string, selects []string, filters []Filter, orderBys []OrderBy, limit int) *QueryOperation

func (*QueryOperation) Collection

func (op *QueryOperation) Collection() string

func (*QueryOperation) IsCollectionGroup added in v0.15.0

func (op *QueryOperation) IsCollectionGroup() bool

func (*QueryOperation) OperationType

func (op *QueryOperation) OperationType() OperationType

type Repl added in v0.4.0

type Repl struct {
	// contains filtered or unexported fields
}

func NewRepl added in v0.4.0

func NewRepl(ctx context.Context, fs *firestore.Client, in io.Reader, out io.Writer, outputMode OutputMode) *Repl

func (*Repl) ProcessLine added in v0.10.0

func (r *Repl) ProcessLine(line string)

func (*Repl) ProcessLineFromPipe added in v0.10.0

func (r *Repl) ProcessLineFromPipe()

func (*Repl) Start added in v0.4.0

func (r *Repl) Start()

type StringFilter

type StringFilter struct {
	BaseFilter
	// contains filtered or unexported fields
}

func NewStringFilter

func NewStringFilter(field string, operator Operator, value string) *StringFilter

func (*StringFilter) Value

func (f *StringFilter) Value() any

type TimestampFilter added in v0.11.0

type TimestampFilter struct {
	BaseFilter
	// contains filtered or unexported fields
}

func NewTimestampFilter added in v0.11.0

func NewTimestampFilter(field string, operator Operator, value time.Time) *TimestampFilter

func (*TimestampFilter) Value added in v0.11.0

func (f *TimestampFilter) Value() any

type Token

type Token struct {
	Type    TokenType
	Literal string
}

type TokenType

type TokenType = string

func LookupIdent

func LookupIdent(ident string) TokenType

func LookupMetacommand added in v0.7.0

func LookupMetacommand(s string) TokenType

Directories

Path Synopsis
cmd
fscli command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL