]> 91.132.146.200 Git - scientia.git/commitdiff
structure overview with a d2 file
authorBanana <mail@bananas-playground.net>
Thu, 18 Jul 2024 20:17:23 +0000 (22:17 +0200)
committerBanana <mail@bananas-playground.net>
Thu, 18 Jul 2024 20:17:23 +0000 (22:17 +0200)
client/go-cli/scientia/cmd/pull.go [new file with mode: 0644]
documentation/structure.d2 [new file with mode: 0644]

diff --git a/client/go-cli/scientia/cmd/pull.go b/client/go-cli/scientia/cmd/pull.go
new file mode 100644 (file)
index 0000000..485e094
--- /dev/null
@@ -0,0 +1,47 @@
+package cmd
+
+import (
+       "fmt"
+       "github.com/spf13/cobra"
+       "io"
+       "os"
+       Helper "scientia/lib"
+)
+
+func init() {
+       rootCmd.AddCommand(pullCmd)
+}
+
+var pullCmd = &cobra.Command {
+       Use: "pull",
+       Short: "Download",
+       Long: "Add a new entry based on a file or piped cat file | scientia add. Returns the url to the new entry.",
+       Run: func(cmd *cobra.Command, args []string) {
+               // check if there is a file or piped content
+               var inputString string
+
+               if len(args) == 1 {
+                       if FlagVerbose {
+                               fmt.Println("Read from file argument")
+                       }
+                       bytes, err := os.ReadFile(args[0])
+                       Helper.ErrorCheck(err, "Error opening file")
+                       inputString = string(bytes)
+               } else if stat, _ := os.Stdin.Stat(); (stat.Mode() & os.ModeCharDevice) == 0  {
+                       if FlagVerbose {
+                               fmt.Println("Read from piped stdin")
+                       }
+                       bytes, _ := io.ReadAll(os.Stdin)
+                       inputString = string(bytes)
+               } else {
+                       cmd.Help()
+                       os.Exit(0)
+               }
+
+               response := upload(inputString)
+
+               // print the result and link to the pasty
+               fmt.Printf("Status: %d\n", response.Status)
+               fmt.Printf("Message: %s\n", response.Message)
+       },
+}
diff --git a/documentation/structure.d2 b/documentation/structure.d2
new file mode 100644 (file)
index 0000000..7bd6269
--- /dev/null
@@ -0,0 +1,69 @@
+sc: scientia
+cfg: config
+cfg_edit: edit
+cfg_init: init
+cfg_read: read
+add: add
+pull: pull
+push: push
+edit: edit
+
+sc -> cfg
+cfg -> cfg_init
+cfg -> cfg_edit
+cfg -> cfg_read
+
+sc -> add
+
+addContainer: add {
+    add_param: file or stdin
+    add_param.shape: oval
+    server: server
+    server.shape: cloud
+    local: local
+    local.shape: page
+
+    add -> add_param
+    add_param -> server
+    server -> local
+    add_param -> local: offline
+}
+
+sc -> pull
+
+pullContainer: pull {
+    server: server
+    server.shape: cloud
+    local: local
+    local.shape: page
+
+    pull -> server
+    server -> local: versions
+}
+
+sc -> push
+
+pushContainer: push {
+    server: server
+    server.shape: cloud
+    local: local
+    local.shape: page
+
+    push -> local
+    local -> server: versions
+}
+
+sc -> edit
+
+editContainer: edit {
+    local: local
+    local.shape: page
+
+    edit_list: list
+    edit_id: id
+
+    edit -> edit_list
+    edit -> edit_id
+
+    edit_id -> local: new version
+}