-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: jans-cli menu for exit, logout and configure
- Loading branch information
1 parent
96fe636
commit 6a04adf
Showing
6 changed files
with
135 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import os | ||
import sys | ||
import asyncio | ||
|
||
from typing import Sequence | ||
|
||
|
||
from prompt_toolkit.application import Application | ||
from prompt_toolkit.layout.containers import HSplit, VSplit, Window, Float | ||
from prompt_toolkit.layout.dimension import D | ||
from prompt_toolkit.widgets import Button, Label, Frame | ||
from prompt_toolkit.formatted_text import HTML | ||
from prompt_toolkit.widgets import Shadow | ||
from prompt_toolkit.layout.controls import FormattedTextControl | ||
|
||
|
||
from utils.multi_lang import _ | ||
from cli import config_cli | ||
|
||
|
||
class Plugin: | ||
"""This is a general class for plugins | ||
""" | ||
def __init__( | ||
self, | ||
app: Application | ||
) -> None: | ||
"""init for Plugin class "Jans CLI Menu" | ||
Args: | ||
app (_type_): _description_ | ||
""" | ||
self.app = app | ||
self.pid = 'jans-menu' | ||
self.name = '[J]ans Cli' | ||
|
||
self.menu_container = Frame( | ||
body=HSplit([ | ||
Button(text=_("Exit Jans CLI"), handler=self.exit_cli), | ||
Button(text=_("Logout and Exit Jans CLI"), handler=self.logout_exit_cli), | ||
Button(text=_("Configure Jans CLI"), handler=self.configure_cli), | ||
], | ||
width=D() | ||
), | ||
height=D() | ||
) | ||
|
||
|
||
def process(self) -> None: | ||
pass | ||
|
||
def set_center_frame(self) -> None: | ||
"""center frame content | ||
""" | ||
|
||
self.app.center_container = self.menu_container | ||
|
||
|
||
def exit_cli(self) -> None: | ||
"""Exits | ||
""" | ||
self.app.exit(result=False) | ||
|
||
|
||
def logout_exit_cli(self) -> None: | ||
"""Removes auth token and exits | ||
""" | ||
del config_cli.config['DEFAULT']['access_token_enc'] | ||
del config_cli.config['DEFAULT']['user_data'] | ||
config_cli.write_config() | ||
self.exit_cli() | ||
|
||
def configure_cli(self) -> None: | ||
"""Configures CLI creds | ||
""" | ||
self.app.jans_creds_dialog() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters