Add preserve_process_environment
This commit is contained in:
parent
2a1a3fe200
commit
e898bc62db
|
@ -13,3 +13,8 @@ Do not send messages immediately to the dataspace passed `json_socket_translator
|
|||
## msg
|
||||
|
||||
A utility that sends a message to $SYNDICATE_SOCK in the form `<ARGV…>`.
|
||||
|
||||
## preserve_process_environment
|
||||
|
||||
This utility serializes it's process environment to Preserves and prints it to stdout.
|
||||
It can be used to feed the environment variables of a nested child of the Syndicate server back to the server. For example, to retreive the environmental variables that a desktop manager passed on to its children.
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
# SPDX-FileCopyrightText: ☭ Emery Hemingway
|
||||
# SPDX-License-Identifier: Unlicense
|
||||
|
||||
import std/[tables, os]
|
||||
import preserves
|
||||
|
||||
type ProcessInfo {.preservesDictionary.} = object
|
||||
program: string
|
||||
argv: seq[string]
|
||||
env: Table[string, string]
|
||||
dir: string
|
||||
|
||||
proc main =
|
||||
var info: ProcessInfo
|
||||
info.program = getAppFilename()
|
||||
info.argv = commandLineParams()
|
||||
for key, val in envPairs(): info.env[key] = val
|
||||
info.dir = getCurrentDir()
|
||||
writeLine(stdout, info.toPreserve)
|
||||
|
||||
main()
|
|
@ -5,7 +5,7 @@ author = "Emery Hemingway"
|
|||
description = "Utilites for Syndicated Actors and Synit"
|
||||
license = "unlicense"
|
||||
srcDir = "src"
|
||||
bin = @["json_socket_translator", "json_translator", "msg"]
|
||||
bin = @["json_socket_translator", "json_translator", "msg", "preserve_process_environment"]
|
||||
|
||||
|
||||
# Dependencies
|
||||
|
|
Loading…
Reference in New Issue