-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Campaign to Save the CLI #161
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
d1b8c59
Fix #128.
thw26 5908cdd
add FIXME
n8marti f92d531
fix typo blocking selection of wine binary
n8marti 5d3774c
add "choose default with Enter" feature
n8marti 2f0b0ff
fix crazy slow MD5 sum calculation
n8marti b43e6dc
use separate events for input_q and choice_q
n8marti c918db5
initial work for --run-installed-app
n8marti 8a82699
additional TODOs, etc.
n8marti 1008fc5
minor CLI fixes
n8marti b63ed02
fix incorrect setting of config.DIALOG as 'cli' when using other DIALOGs
n8marti 075da8f
add TODO
n8marti aa8fc02
use single func wine.wineserver_wait; log if procs still using WINEPR…
n8marti 11315d1
only kill wine procs in close func if exiting from Control Panel
n8marti b3fce6e
fix --set-appimage CLI subcommand
n8marti 0814ecd
update list of subcommands that assume Logos is already installed
n8marti 96280de
convert all actions to cli app methods
n8marti a28a838
add TODO
n8marti f71731e
add TODO
n8marti File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,201 @@ | ||
# import logging | ||
import queue | ||
import threading | ||
|
||
import config | ||
import control | ||
import installer | ||
import logos | ||
# import msg | ||
import wine | ||
import utils | ||
|
||
|
||
class CLI: | ||
def __init__(self): | ||
config.DIALOG = "cli" | ||
self.running = True | ||
self.choice_q = queue.Queue() | ||
self.input_q = queue.Queue() | ||
self.input_event = threading.Event() | ||
self.choice_event = threading.Event() | ||
self.logos = logos.LogosManager(app=self) | ||
|
||
def backup(self): | ||
control.backup() | ||
|
||
def edit_config(self): | ||
control.edit_config() | ||
|
||
def get_winetricks(self): | ||
control.set_winetricks() | ||
|
||
def install_app(self): | ||
self.thread = utils.start_thread( | ||
installer.ensure_launcher_shortcuts, | ||
app=self | ||
) | ||
self.user_input_processor() | ||
|
||
def install_d3d_compiler(self): | ||
wine.install_d3d_compiler() | ||
|
||
def install_dependencies(self): | ||
utils.check_dependencies() | ||
|
||
def install_fonts(self): | ||
wine.install_fonts() | ||
|
||
def install_icu(self): | ||
wine.install_icu_data_files() | ||
|
||
def remove_index_files(self): | ||
control.remove_all_index_files() | ||
|
||
def remove_install_dir(self): | ||
control.remove_install_dir() | ||
|
||
def remove_library_catalog(self): | ||
control.remove_library_catalog() | ||
|
||
def restore(self): | ||
control.restore() | ||
|
||
def run_indexing(self): | ||
self.logos.index() | ||
|
||
def run_installed_app(self): | ||
self.logos.start() | ||
|
||
def run_winetricks(self): | ||
wine.run_winetricks() | ||
|
||
def set_appimage(self): | ||
utils.set_appimage_symlink(app=self) | ||
|
||
def stop(self): | ||
self.running = False | ||
|
||
def toggle_app_logging(self): | ||
self.logos.switch_logging() | ||
|
||
def update_latest_appimage(self): | ||
utils.update_to_latest_recommended_appimage() | ||
|
||
def update_self(self): | ||
utils.update_to_latest_lli_release() | ||
|
||
def user_input_processor(self, evt=None): | ||
while self.running: | ||
prompt = None | ||
question = None | ||
options = None | ||
choice = None | ||
# Wait for next input queue item. | ||
self.input_event.wait() | ||
self.input_event.clear() | ||
prompt = self.input_q.get() | ||
if prompt is None: | ||
return | ||
if prompt is not None and isinstance(prompt, tuple): | ||
question = prompt[0] | ||
options = prompt[1] | ||
if question is not None and options is not None: | ||
# Convert options list to string. | ||
default = options[0] | ||
options[0] = f"{options[0]} [default]" | ||
optstr = ', '.join(options) | ||
choice = input(f"{question}: {optstr}: ") | ||
if len(choice) == 0: | ||
choice = default | ||
if choice is not None and choice.lower() == 'exit': | ||
self.running = False | ||
if choice is not None: | ||
self.choice_q.put(choice) | ||
self.choice_event.set() | ||
|
||
|
||
# NOTE: These subcommands are outside the CLI class so that the class can be | ||
# instantiated at the moment the subcommand is run. This lets any CLI-specific | ||
# code get executed along with the subcommand. | ||
def backup(): | ||
CLI().backup() | ||
|
||
|
||
def create_shortcuts(): | ||
# TODO: This takes surprisingly long because it walks through all the | ||
# installer steps to confirm everything up to the shortcuts. Can this be | ||
# shortcutted? | ||
CLI().install_app() | ||
|
||
|
||
def edit_config(): | ||
CLI().edit_config() | ||
|
||
|
||
def get_winetricks(): | ||
CLI().get_winetricks() | ||
|
||
|
||
def install_app(): | ||
CLI().install_app() | ||
|
||
|
||
def install_d3d_compiler(): | ||
CLI().install_d3d_compiler() | ||
|
||
|
||
def install_dependencies(): | ||
CLI().install_dependencies() | ||
|
||
|
||
def install_fonts(): | ||
CLI().install_fonts() | ||
|
||
|
||
def install_icu(): | ||
CLI().install_icu() | ||
|
||
|
||
def remove_index_files(): | ||
CLI().remove_index_files() | ||
|
||
|
||
def remove_install_dir(): | ||
CLI().remove_install_dir() | ||
|
||
|
||
def remove_library_catalog(): | ||
CLI().remove_library_catalog() | ||
|
||
|
||
def restore(): | ||
CLI().restore() | ||
|
||
|
||
def run_indexing(): | ||
CLI().run_indexing() | ||
|
||
|
||
def run_installed_app(): | ||
CLI().run_installed_app() | ||
|
||
|
||
def run_winetricks(): | ||
CLI().run_winetricks() | ||
|
||
|
||
def set_appimage(): | ||
CLI().set_appimage() | ||
|
||
|
||
def toggle_app_logging(): | ||
CLI().toggle_app_logging() | ||
|
||
|
||
def update_latest_appimage(): | ||
CLI().update_latest_appimage() | ||
|
||
|
||
def update_self(): | ||
CLI().update_self() |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is fixed in #182