style input
This commit is contained in:
parent
ac3dc44c56
commit
d0c7622dc6
1 changed files with 21 additions and 6 deletions
27
promcli.py
27
promcli.py
|
@ -2,14 +2,18 @@
|
|||
|
||||
import netrc
|
||||
from datetime import datetime
|
||||
from tabulate import tabulate
|
||||
|
||||
import click
|
||||
import requests
|
||||
from tabulate import tabulate
|
||||
from prompt_toolkit import print_formatted_text as print
|
||||
from prompt_toolkit import HTML
|
||||
from prompt_toolkit import prompt as prompt
|
||||
from prompt_toolkit.completion import WordCompleter
|
||||
from prompt_toolkit import prompt
|
||||
from prompt_toolkit.completion import ThreadedCompleter, FuzzyWordCompleter
|
||||
from prompt_toolkit.lexers import PygmentsLexer
|
||||
from prompt_toolkit.styles import style_from_pygments_cls
|
||||
from pygments.lexers.promql import PromQLLexer
|
||||
from pygments.styles.solarized import SolarizedLightStyle
|
||||
|
||||
|
||||
class promcli(object):
|
||||
|
@ -76,9 +80,20 @@ def cli(ctx, user, password, promhost, use_netrc):
|
|||
@click.pass_context
|
||||
def query(ctx):
|
||||
promclio = ctx.obj['promcli']
|
||||
query = prompt("query: ", completer=WordCompleter(promclio.get_series()))
|
||||
params = prompt("{ ", completer=WordCompleter(promclio.get_labels(query)))
|
||||
print(HTML(f"Querying <blue>{query}{{{params}}}</blue>"))
|
||||
query = prompt(
|
||||
"query: ",
|
||||
completer=FuzzyWordCompleter(promclio.get_series()),
|
||||
lexer=PygmentsLexer(PromQLLexer),
|
||||
style=style_from_pygments_cls(SolarizedLightStyle),
|
||||
)
|
||||
params = prompt(
|
||||
"{ ",
|
||||
completer=FuzzyWordCompleter(promclio.get_labels(query)),
|
||||
complete_in_thread=True,
|
||||
lexer=PygmentsLexer(PromQLLexer),
|
||||
style=style_from_pygments_cls(SolarizedLightStyle),
|
||||
)
|
||||
print(HTML(f"Querying <lightblue>{query}{{{params}}}</lightblue>"))
|
||||
print(promclio.format_query(promclio.get_query(f"{query}{{{params}}}")))
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue