-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(api.ServeRPC): serve core methods over RPC
this commit builds upon intial work to make all core methods available as RPC. this isn't finished as of yet, given that all in and out params will need to conform to encoding/gob specs, which basically boils down to using only Exported types. I think this is a good opportunity to have *all* params to core methods be declared in the core package itself (these could be aliases to underlying types if needed). TODO: * finish implementation * write test suite that works core methods over RPC
- Loading branch information
Showing
16 changed files
with
299 additions
and
40 deletions.
There are no files selected for viewing
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
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,74 @@ | ||
package cmd | ||
|
||
import ( | ||
"encoding/json" | ||
"os" | ||
|
||
"github.com/qri-io/qri/core" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var ( | ||
setProfileFilepath string | ||
) | ||
|
||
// profileCmd represents the profile command | ||
var profileCmd = &cobra.Command{ | ||
Use: "profile", | ||
Short: "show or edit user profile information", | ||
} | ||
|
||
var profileGetCmd = &cobra.Command{ | ||
Use: "get", | ||
Short: "get profile info", | ||
Run: func(cmd *cobra.Command, args []string) { | ||
r, err := ProfileRequests(false) | ||
ExitIfErr(err) | ||
|
||
in := true | ||
res := &core.Profile{} | ||
err = r.GetProfile(&in, res) | ||
ExitIfErr(err) | ||
|
||
data, err := json.MarshalIndent(res, "", " ") | ||
ExitIfErr(err) | ||
PrintSuccess(string(data)) | ||
}, | ||
} | ||
|
||
var profileSetCmd = &cobra.Command{ | ||
Use: "set", | ||
Short: "add peers to the profile list", | ||
Run: func(cmd *cobra.Command, args []string) { | ||
var ( | ||
dataFile *os.File | ||
err error | ||
) | ||
|
||
r, err := ProfileRequests(false) | ||
ExitIfErr(err) | ||
|
||
dataFile, err = loadFileIfPath(setProfileFilepath) | ||
ExitIfErr(err) | ||
|
||
p := &core.Profile{} | ||
err = json.NewDecoder(dataFile).Decode(p) | ||
ExitIfErr(err) | ||
|
||
res := &core.Profile{} | ||
err = r.SaveProfile(p, res) | ||
ExitIfErr(err) | ||
|
||
data, err := json.MarshalIndent(res, "", " ") | ||
ExitIfErr(err) | ||
PrintSuccess(string(data)) | ||
}, | ||
} | ||
|
||
func init() { | ||
profileSetCmd.Flags().StringVarP(&setProfileFilepath, "file", "f", "", "json file to update profile info") | ||
|
||
profileCmd.AddCommand(profileGetCmd) | ||
profileCmd.AddCommand(profileSetCmd) | ||
RootCmd.AddCommand(profileCmd) | ||
} |
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
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
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
Oops, something went wrong.