define

command module
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2024 License: MIT Imports: 16 Imported by: 0

README

define

Build Status Go Report Card Latest Stable Version

A command-line dictionary (thesaurus) app, with access to multiple sources, written in Go.

screen shot 2018-03-21 at 8 51 54 pm

Install

Pre-compiled binaries are available on the releases page.

If you have a working Go environment, you can install via go install:

go install github.com/Rican7/define@latest

Configuration

The define app allows configuration through multiple means. You can either set configuration via:

  1. Command line flags (good for one-off use)
  2. Environment variables (good for API keys)
  3. A configuration file (good for your "dotfiles")

When multiple means of configuration are used, the values will take precedence in the aforementioned priority.

Command line flags

The list of command line flags is easily discovered via the --help flag. Any passed command line flag will take precedence over any other configuration mechanism.

Environment variables

Some configuration values can also be specified via environment variables. This is especially useful for API keys of different sources.

The following environment variables are read by define's sources:

  • MERRIAM_WEBSTER_DICTIONARY_APP_KEY
  • OXFORD_DICTIONARY_APP_ID
  • OXFORD_DICTIONARY_APP_KEY
Configuration file

A configuration file can be stored that define will automatically load the values from.

The path of the configuration file to load can be specified via the --config-file flag. If no config file path is specified, define will search for a config file in your OS's standard config directory paths. While these paths are OS-specific, there are two locations that are searched for that are shared among all platforms:

  1. $XDG_CONFIG_HOME/define/config.json (This is only searched for when the $XDG_CONFIG_HOME env variable is set)
  2. ~/.define.conf.json (Where ~ is equal to your $HOME or user directory for your OS)

To see which config file has been loaded, and to check what paths are searched for config files, use the --debug-config flag.

To print the default values of the configuration, simply use the --print-config flag. This can also be used to initialize a configuration file, for example:

define --print-config > ~/.define.conf.json

Sources

The define app has access to multiple sources, however some of them require user-specific API keys, due to usage limitations.

A preferred source can be specified with the command line flag --preferred-source="..." or in a configuration file. For more information, see the section on Configuration.

Obtaining API keys

The following are links to register for API keys for the different sources:

Documentation

Overview

A command-line dictionary (thesaurus) app, written in Go.

Directories

Path Synopsis
internal
action
Package action provides types for determining the action intended to be performed by the application.
Package action provides types for determining the action intended to be performed by the application.
config
Package config provides types and handling for configuration values used in the application.
Package config provides types and handling for configuration values used in the application.
io
Package io provides types that enable easy and more consistent input/output by wrapping the standard types
Package io provides types that enable easy and more consistent input/output by wrapping the standard types
io/printer
Package printer provides types and methods to encapsulate consistent printing of structures.
Package printer provides types and methods to encapsulate consistent printing of structures.
version
Package version provides application version information
Package version provides application version information
Package registry provides a registry for sources and their providers to integrate into the source list
Package registry provides a registry for sources and their providers to integrate into the source list
Package source defines interfaces to be implemented by dictionary sources and common structures and operations for those implementations to use.
Package source defines interfaces to be implemented by dictionary sources and common structures and operations for those implementations to use.
freedictionaryapi
Package freedictionaryapi provides a dictionary source via the "Free Dictionary API"
Package freedictionaryapi provides a dictionary source via the "Free Dictionary API"
oxford
Package oxford provides a dictionary source via the Oxford Dictionaries API
Package oxford provides a dictionary source via the Oxford Dictionaries API
webster
Package webster provides a dictionary source via the Webster Dictionaries API
Package webster provides a dictionary source via the Webster Dictionaries API

Jump to

Keyboard shortcuts

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