From ff258dde2d5f18078153c3283184b31bdad5a57a Mon Sep 17 00:00:00 2001 From: Vladimir Hodakov Date: Sat, 30 Mar 2019 04:44:51 +0400 Subject: [PATCH] Add README and upload function stub --- README.md | 9 +++++++++ domains/yandex/v1/exported.go | 21 +++++++++++++++++++++ domains/yandex/v1/help.go | 15 +++++++++++++++ domains/yandex/v1/requests.go | 2 ++ 4 files changed, 47 insertions(+) create mode 100644 README.md create mode 100644 domains/yandex/v1/help.go diff --git a/README.md b/README.md new file mode 100644 index 0000000..ba7e5c2 --- /dev/null +++ b/README.md @@ -0,0 +1,9 @@ +# Yandex.Disk File Pusher + +## English + +This app is useful when you want to upload single file to Yandex.Disk but don't want to fiddle with sync official client or WebDAV. It is especially useful for automating backups (e. g. in conjuction with Proxmox's ``vzdump``.) + +## Russian + +Эта утилита полезна, если вы хотите загрузить единичный файл на Яндекс.Диск, но не хотите связываться с полноценным приложением для синхронизации или WebDAV. Особенно такая утилита полезна для автоматизации заливки резервных копий (например, в связке с ``vzdump`` из состава Proxmox). \ No newline at end of file diff --git a/domains/yandex/v1/exported.go b/domains/yandex/v1/exported.go index 524e65a..74bad95 100644 --- a/domains/yandex/v1/exported.go +++ b/domains/yandex/v1/exported.go @@ -30,6 +30,20 @@ func New(cc *context.Context) { DefaultValue: 0000000, }) + _ = c.Flagger.AddFlag(&flagger.Flag{ + Name: "uploadPath", + Description: "Path to upload your file on Yandex.Disk. Must exist before uploading.", + Type: "string", + DefaultValue: "/", + }) + + _ = c.Flagger.AddFlag(&flagger.Flag{ + Name: "file", + Description: "Path to file that will be uploaded. Max upload size - 50 GB", + Type: "string", + DefaultValue: "", + }) + dlog.Info().Msg("Domain initialized") } @@ -40,7 +54,14 @@ func Process() { sendCode(authCode) } + filePath, _ := c.Flagger.GetStringValue("file") + if filePath != "" { + uploadFile() + } + if !checkAuth() { authorize() } + + showHelp() } diff --git a/domains/yandex/v1/help.go b/domains/yandex/v1/help.go new file mode 100644 index 0000000..a6f67a8 --- /dev/null +++ b/domains/yandex/v1/help.go @@ -0,0 +1,15 @@ +// Yandex Disk File Pusher +// Copyright (c) 2019 Vladimir "fat0troll" Hodakov + +package yandexv1 + +import ( + "os" +) + +func showHelp() { + dlog.Info().Msg("This app is authorized for uploading your files one by one to Yandex.Disk.") + dlog.Info().Msg("For information how to use this app, run yapusher with -h flag or head to https://github.com/fat0troll/yapusher/blob/master/README.") + + os.Exit(0) +} diff --git a/domains/yandex/v1/requests.go b/domains/yandex/v1/requests.go index 02df171..dd95f76 100644 --- a/domains/yandex/v1/requests.go +++ b/domains/yandex/v1/requests.go @@ -57,3 +57,5 @@ func sendCode(code int) { os.Exit(0) } + +func uploadFile() {}