Skip to content

gole.cli

gole.cli πŸ”—

default(path: str = '.') πŸ”—

Simple editor for simple things.

Parameters:

Name Type Description Default
path str

File or directory to be worked.

.
Source code in gole/cli.py
@app.default
def default(path: str = '.'):
    """Simple editor for simple things.

    Parameters
    ----------
    path : str, default=.
        File or directory to be worked.
    """
    Gole(AsyncPath(path), Path.cwd()).run()

list() πŸ”—

List the active configuration.

Source code in gole/cli.py
@app[CONFIG_CMD].command
def list():
    """List the active configuration."""
    table = Table(title='Configs')
    table.add_column('OPTION', style='cyan')
    table.add_column('VALUE', style='white')

    for option in settings.options:
        table.add_row(option, str(settings[option]))

    console.print(table)

edit() πŸ”—

Edit the configuration file in the editor.

Source code in gole/cli.py
@app[CONFIG_CMD].command
def edit():
    """Edit the configuration file in the editor."""
    cwd = Path.cwd()
    Gole(cwd, cwd, open_settings_on_mount=True).run()

get(option: Options) πŸ”—

Get the value associated with OPTION.

Parameters:

Name Type Description Default
option Options

Option to look for the value.

required
Source code in gole/cli.py
@app[CONFIG_CMD].command
def get(option: Options):
    """Get the value associated with OPTION.

    Parameters
    ----------
    option : Options
        Option to look for the value.
    """
    table = Table(title='Configs')
    table.add_column('OPTION', style='cyan')
    table.add_column('VALUE', style='white')

    table.add_row(option, str(settings[option]))
    console.print(table)

set(option: Options, value: str) async πŸ”—

Set the OPTION VALUE.

Parameters:

Name Type Description Default
option Options

Option to be changed.

required
value str

Value to be defined.

required
Source code in gole/cli.py
@app[CONFIG_CMD].command
async def set(option: Options, value: str):
    """Set the OPTION VALUE.

    Parameters
    ----------
    option : Options
        Option to be changed.
    value : str
        Value to be defined.
    """
    try:
        await settings.save(**{option: value})
    except Exception as error:
        panel = Panel.fit(
            Text.from_markup(f'{error}', justify='center'),
            title='Error',
            border_style='red',
        )
        console.print(panel)
        return True

    panel = Panel.fit(
        Text.from_markup(
            f'setted:  [cyan]{option.upper()}[/] = {value}',
            justify='center',
        ),
        title='Success',
        border_style='green',
    )
    console.print(panel)