Allow setting sbotcli path using environment variable #1

Open
opened 2021-11-03 14:01:56 +00:00 by glyph · 5 comments
Owner

Check for the SBOTCLI_PATH env var: if it exists, use it when constructing commands to invoke sbotcli; if it does not exist, use a default path.

We need to try and make this modular so that it plays nicely as a standalone library and when imported into peach-web.

Check for the `SBOTCLI_PATH` env var: if it exists, use it when constructing commands to invoke `sbotcli`; if it does not exist, use a default path. We need to try and make this modular so that it plays nicely as a standalone library and when imported into `peach-web`.
glyph added the
enhancement
label 2021-11-03 14:02:10 +00:00
Owner

^^ sounds good.

As I mentioned in this comment 1aa5821adf/peach-lib/src/sbot_client.rs (L18),

currently go-sbotcli determines where the working directory is
using the home directory of the user that invokes it, which is why in sbot_client I was running commands as peach-go-sbot.

Now that we have the assistance of @cblgh,

  1. we should probably make a PR to go-sbot to allow setting the working directory using a CLI flag (or env var),

  2. similar to your issue above, we could make it so this rust library allows for setting the working directory using an env var or CLI flag, which then gets passed along to go-sbot

After both of the above, we can then use this library directly from peach-web.

^^ sounds good. As I mentioned in this comment https://git.coopcloud.tech/PeachCloud/peach-workspace/src/commit/1aa5821adf3b93509635c4c68f417a2340dc1969/peach-lib/src/sbot_client.rs#L18, currently go-sbotcli determines where the working directory is using the home directory of the user that invokes it, which is why in sbot_client I was running commands as peach-go-sbot. Now that we have the assistance of @cblgh, 1. we should probably make a PR to go-sbot to allow setting the working directory using a CLI flag (or env var), 2. similar to your issue above, we could make it so this rust library allows for setting the working directory using an env var or CLI flag, which then gets passed along to go-sbot After both of the above, we can then use this library directly from peach-web.
Owner

could also consider to do an object-oriented pattern, with something like:

  • a function to instantiate an SbotcliApi object (with optional arguments to pass flags like sbotcli_path, and working directory, or maybe other thing not thinking of)
  • and then all the specific API calls are methods of SbotcliApi object (and pass along the flags appropriately when called)

this might be the most modular

could also consider to do an object-oriented pattern, with something like: - a function to instantiate an SbotcliApi object (with optional arguments to pass flags like sbotcli_path, and working directory, or maybe other thing not thinking of) - and then all the specific API calls are methods of SbotcliApi object (and pass along the flags appropriately when called) this might be the most modular
Owner

not sure if it makes more sense for a rust library to be configured via env variables, or explicitly via instantiating an object with arguments, or both.

perhaps with an object is more modular, because a user of the library could always write their own thing which looks for env variables and then instantiates the object correctly,

but I would be curious to see what other rust libraries and API wrappers do

not sure if it makes more sense for a rust library to be configured via env variables, or explicitly via instantiating an object with arguments, or both. perhaps with an object is more modular, because a user of the library could always write their own thing which looks for env variables and then instantiates the object correctly, but I would be curious to see what other rust libraries and API wrappers do
Owner

also for ergonomics, SbotcliApi object could just be called Sbot

also for ergonomics, SbotcliApi object could just be called Sbot
Author
Owner

PR to go-sbot to allow setting the working directory using a CLI flag (or env var)

+1 to this idea.

could also consider to do an object-oriented pattern

Good call! I had totally neglected to consider an object-oriented pattern. I'll take a look at implementing it and see how it feels to work with.

not sure if it makes more sense for a rust library to be configured via env variables, or explicitly via instantiating an object with arguments, or both.

I tend to agree with you that configuration via object parameter is more practical in a library (offered greater flexibility for the library users).

> PR to go-sbot to allow setting the working directory using a CLI flag (or env var) +1 to this idea. > could also consider to do an object-oriented pattern Good call! I had totally neglected to consider an object-oriented pattern. I'll take a look at implementing it and see how it feels to work with. > not sure if it makes more sense for a rust library to be configured via env variables, or explicitly via instantiating an object with arguments, or both. I tend to agree with you that configuration via object parameter is more practical in a library (offered greater flexibility for the library users).
Sign in to join this conversation.
No description provided.