import pathlib
import subprocess
from typing import Literal, overload
class Tool:
def __init__(self, path: pathlib.Path) -> None:
self.path = path
@staticmethod
@overload
def _run(
*args: str | pathlib.Path,
cwd: pathlib.Path,
capture_output: bool = ...,
check: bool = ...,
text: Literal[True] = ...,
) -> subprocess.CompletedProcess[str]:
...
@staticmethod
@overload
def _run(
*args: str | pathlib.Path,
cwd: pathlib.Path,
capture_output: bool = ...,
check: bool = ...,
text: Literal[False],
) -> subprocess.CompletedProcess[bytes]:
...
@staticmethod
@overload
def _run(
*args: str | pathlib.Path,
cwd: pathlib.Path,
capture_output: bool = ...,
check: bool = ...,
text: bool = ...,
) -> subprocess.CompletedProcess[str] | subprocess.CompletedProcess[bytes]:
...
@staticmethod
def _run(
*args: str | pathlib.Path,
cwd: pathlib.Path,
capture_output: bool = True,
check: bool = True,
text: bool = True,
) -> subprocess.CompletedProcess[str] | subprocess.CompletedProcess[bytes]:
# actually does some more work with error handling and such
return subprocess.run(
["..."] + list(args),
cwd=cwd,
text=text,
capture_output=capture_output,
check=check,
)
@overload
def run(
self,
*args: str | pathlib.Path,
capture_output: bool = ...,
check: bool = ...,
text: Literal[True] = ...,
) -> subprocess.CompletedProcess[str]:
...
@overload
def run(
self,
*args: str | pathlib.Path,
capture_output: bool = ...,
check: bool = ...,
text: Literal[False],
) -> subprocess.CompletedProcess[bytes]:
...
@overload
def run(
self,
*args: str | pathlib.Path,
capture_output: bool = ...,
check: bool = ...,
text: bool = ...,
) -> subprocess.CompletedProcess[str] | subprocess.CompletedProcess[bytes]:
...
def run(
self,
*args: str | pathlib.Path,
capture_output: bool = True,
check: bool = True,
text: bool = True,
) -> subprocess.CompletedProcess[str] | subprocess.CompletedProcess[bytes]:
return Tool._run(
*args,
cwd=self.path,
capture_output=capture_output,
check=check,
text=text,
)
{"text":"text","html5":"html","css":"css","javascript":"javascript","php":"php","python":"python","ruby":"ruby","lua":"lua","bash":"sh","erlang":"erlang","go":"golang","c":"c_cpp","cpp":"c_cpp","diff":"diff","latex":"latex","sql":"sql","xml":"xml","0":"text","abap":"abap","actionscript":"actionscript","actionscript3":"actionscript","ada":"ada","apache":"apache_conf","applescript":"applescript","asm":"assembly_x86","autohotkey":"autohotkey","closure":"closure","cobol":"cobol","coffeescript":"coffee","cpp-winapi":"c_cpp","c_loadrunner":"c_cpp","c_mac":"c_cpp","c_winapi":"c_cpp","csharp":"csharp","d":"d","dart":"dart","dot":"dot","eiffel":"eiffel","fortran":"fortran","groovy":"groovy","haskell":"haskell","haxe":"haxe","ini":"ini","io":"io","java":"java","java5":"java","make":"makefile","matlab":"matlab","mysql":"mysql","objc":"objectivec","ocaml":"ocaml","pascal":"pascal","perl":"perl","perl6":"perl","postgresql":"pgsql","powershell":"powershell","prolog":"prolog","properties":"properties","rails":"ruby","rust":"rust","scala":"scala","scheme":"scheme","smarty":"smarty","tcl":"tcl","vala":"vala","vb":"vbscript","verilog":"verilog","vhdl":"vhdl","yaml":"yaml"}