add stub test, add pyproject.toml, add basic structure
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
import shlex
|
||||
import subprocess
|
||||
from typing import Dict, Optional
|
||||
|
||||
|
||||
def run(command: str, stdin: Optional[str] = None) -> Dict[str, str]:
|
||||
process = _execute(command, stdin)
|
||||
|
||||
return {
|
||||
"stdout": process.stdout,
|
||||
"stderr": process.stderr,
|
||||
}
|
||||
|
||||
|
||||
def _parse_command(command: str) -> list[str]:
|
||||
# return command.split()
|
||||
return shlex.split(command)
|
||||
|
||||
|
||||
def _execute(command: str, stdin: Optional[str] = None) -> subprocess.CompletedProcess:
|
||||
parsed_command = _parse_command(command)
|
||||
result = subprocess.run(
|
||||
parsed_command, input=stdin, text=True, capture_output=True, shell=True
|
||||
)
|
||||
return result
|
||||
@@ -0,0 +1,6 @@
|
||||
def main() -> None:
|
||||
print("nexus-sync server")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user