-
Notifications
You must be signed in to change notification settings - Fork 21
Open
Description
Although the current promptshell can implement commands through API's and local models , this approach is slow and time consuming for veteran linux users (and even slightly experienced users can use commands like ls , cp , cd etc commands easily) hence here is my solution , make separate mode for "Translating" linux commands into windows commands.
How i plan to implement this:
The Main Loop (REPL):
- Starts when the user runs python tool.py.
- Displays a custom prompt (e.g., PromptShell C:\Users\You>).
- Continuously reads user input line by line.
- Calls the Eval engine for each line.
- Prints the result or error from the Eval engine.
- Exits on a special command (e.g., exit).
The Parser:
Input: A raw string from the user (e.g., rm -rf "my folder").
Processing:
- Splits the string into a command name, a list of individual flags, and a list of arguments.
- correctly handle quoted arguments containing spaces.
- expand combined flags (e.g., -rf becomes ['-r', '-f']).
Structure:
A clean data structure, for example, a tuple: ('rm', ['-r', '-f'], ['my folder']).
The Command Dispatcher & Handlers:
Dispatcher: A central dictionary (COMMAND_HANDLERS) that maps command names (strings) to handler functions.
- Handler Functions (e.g., handle_rm, handle_mv):
- Input: The lists of flags and arguments from the Parser.
- Processing: Contains the specific logic for one command. It normalizes paths (replacing / with ) and uses f-strings to build the final, precise PowerShell command string.
- Output: A single string which is the fully translated PowerShell command.
- Internal Commands: The cd command handler will be special. It will not return a string to execute; instead, it will directly change the Python script's current working directory using os.chdir().
- The Execution Engine:
Input: The PowerShell command string returned by a handler function.
Processing:
Uses Python's subprocess module to run the command string within PowerShell.
Captures both standard output and standard error from the PowerShell process.
Combiner:
the final output will use some string manipulation to stich together the fianl command for windows
Metadata
Metadata
Assignees
Labels
No labels