Skip to content

Commit

Permalink
shell mode for bottles-cli
Browse files Browse the repository at this point in the history
needed by launchers like itchio
  • Loading branch information
mirkobrombin committed May 29, 2022
1 parent 3e40793 commit ebcd8ae
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/cli.in
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ from bottles.backend.models.samples import Samples
from bottles.backend.wine.cmd import CMD
from bottles.backend.wine.control import Control
from bottles.backend.wine.executor import WineExecutor
from bottles.backend.wine.winecommand import WineCommand
from bottles.backend.wine.reg import Reg
from bottles.backend.wine.regedit import Regedit
from bottles.backend.wine.taskmgr import Taskmgr
Expand Down Expand Up @@ -126,6 +127,10 @@ class CLI:
run_parser.add_argument("-a", "--args", help="Arguments to pass to the executable")
run_parser.add_argument("-p", "--program", help="Program to run")

shell_parser = subparsers.add_parser("shell", help="Launch commands in a Wine shell")
shell_parser.add_argument("-b", "--bottle", help="Bottle name", required=True)
shell_parser.add_argument("-i", "--input", help="Command to execute", required=True)

self.__process_args()

@staticmethod
Expand Down Expand Up @@ -173,6 +178,11 @@ class CLI:
elif self.args.command == "run":
self.run_program()

# SHELL parser
elif self.args.command == "shell":
print("shell")
self.run_shell()

# region INFO
def show_info(self):
_type = self.args.type
Expand Down Expand Up @@ -490,6 +500,24 @@ class CLI:

# endregion

# region SHELL
def run_shell(self):
self.utils_conn = ConnectionUtils(force_offline=True) # avoid manager checks
_bottle = self.args.bottle
_input = self.args.input
mng = Manager(self, is_cli=True)
mng.checks()

if _bottle not in mng.local_bottles:
sys.stderr.write(f"Bottle {_bottle} not found\n")
exit(1)

bottle = mng.local_bottles[_bottle]
winecommand = WineCommand(config=bottle, command=_input)
winecommand.run()

# endregion


if __name__ == '__main__':
cli = CLI()

0 comments on commit ebcd8ae

Please sign in to comment.