-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: more complicated runenv stubs. python runenv stub
- Loading branch information
Showing
5 changed files
with
123 additions
and
43 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,41 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"path/filepath" | ||
"strings" | ||
"time" | ||
) | ||
|
||
func main() { | ||
cmdName := os.Args[0] | ||
if len(os.Args) == 1 { | ||
fmt.Fprintf(os.Stdout, "%q of python run environment was started with no command and arguments", cmdName) | ||
} | ||
|
||
const venvDir = "./venv" | ||
const columnWidth = 8 | ||
|
||
err := os.MkdirAll(venvDir, 0o750) | ||
if err != nil { | ||
panic(fmt.Errorf("python stub: failed to create %q dir: %w", venvDir, err)) | ||
} | ||
|
||
argsReport := strings.Builder{} | ||
|
||
fmt.Fprintf(&argsReport, "%*s = %q\n", columnWidth, "cmd", cmdName) | ||
for i, a := range os.Args[1:] { | ||
argStr := fmt.Sprintf("arg[%d]", i) | ||
fmt.Fprintf(&argsReport, "%*s = %q\n", columnWidth, argStr, a) | ||
} | ||
fmt.Fprintf(&argsReport, "%*s = %d", columnWidth, "time", time.Now().Unix()) | ||
|
||
contentFileValue := argsReport.String() + "\n" | ||
|
||
contentFilePath := filepath.Join(venvDir, cmdName+".txt") | ||
err = os.WriteFile(contentFilePath, []byte(contentFileValue), 0o640) | ||
|
||
fmt.Fprintf(os.Stdout, "file %q created\n", contentFilePath) | ||
fmt.Fprint(os.Stdout, contentFileValue) | ||
} |
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