Refactor to use an object-oriented pattern for Sbot #2

Merged
glyph merged 5 commits from sbot_object into main 2021-11-05 10:45:05 +00:00
Owner

This PR takes the previously-implemented sbotcli functions and converts them into methods on the Sbot struct. An init() constructor method has been added for initialising the Sbot struct. It takes two Option<OsString> args as parameters; one representing the sbotcli path and the other representing the go-sbot working directory. None can be provided to use the default path.

Thanks @notplants for the suggestion.

The code example tells the story:

use peach_sbotcli::{Sbot, SbotCliError};

fn example() -> Result<(), SbotCliError> {
    // uses default paths for `sbotcli` and `go-sbot` working directory
    let sbot = Sbot::init(None, None)?;

    let id = "@p13zSAiOpguI9nsawkGijsnMfWmFd5rlUNpzekEE+vI=.ed25519";

    let follow_ref = sbot.follow(id)?;
    let block_ref = sbot.block(id)?;

    let invite_code = sbot.create_invite()?;

    Ok(())
}
This PR takes the previously-implemented `sbotcli` functions and converts them into methods on the `Sbot` `struct`. An `init()` constructor method has been added for initialising the `Sbot` `struct`. It takes two `Option<OsString>` args as parameters; one representing the `sbotcli` path and the other representing the `go-sbot` working directory. `None` can be provided to use the default path. Thanks @notplants for [the suggestion](https://git.coopcloud.tech/PeachCloud/peach-sbotcli/issues/1#issuecomment-10004). The code example tells the story: ```rust use peach_sbotcli::{Sbot, SbotCliError}; fn example() -> Result<(), SbotCliError> { // uses default paths for `sbotcli` and `go-sbot` working directory let sbot = Sbot::init(None, None)?; let id = "@p13zSAiOpguI9nsawkGijsnMfWmFd5rlUNpzekEE+vI=.ed25519"; let follow_ref = sbot.follow(id)?; let block_ref = sbot.block(id)?; let invite_code = sbot.create_invite()?; Ok(()) } ```
glyph added 4 commits 2021-11-04 15:03:19 +00:00
glyph added the
refactor
label 2021-11-04 15:03:31 +00:00
glyph requested review from notplants 2021-11-04 15:03:44 +00:00
glyph added 1 commit 2021-11-05 09:02:00 +00:00
notplants approved these changes 2021-11-05 10:36:35 +00:00
notplants left a comment
Owner

LGTM

LGTM
Author
Owner

🙏 🖤

🙏 🖤
glyph merged commit e8e31cf9ce into main 2021-11-05 10:45:05 +00:00
glyph deleted branch sbot_object 2021-11-05 10:45:05 +00:00
Sign in to join this conversation.
No description provided.