mirror of
https://codeberg.org/scip/ephemerup.git
synced 2025-12-17 04:30:57 +01:00
implemented various things
This commit is contained in:
@@ -29,6 +29,7 @@ type Config struct {
|
||||
Endpoint string
|
||||
Debug bool
|
||||
Retries int
|
||||
Expire string
|
||||
}
|
||||
|
||||
func Getversion() string {
|
||||
|
||||
@@ -87,7 +87,8 @@ func Execute() {
|
||||
rootCmd.PersistentFlags().BoolVarP(&conf.Debug, "debug", "d", false, "Enable debugging")
|
||||
rootCmd.PersistentFlags().StringVarP(&cfgFile, "config", "c", "", "custom config file")
|
||||
rootCmd.PersistentFlags().IntVarP(&conf.Retries, "retries", "r", 3, "How often shall we retry to access our endpoint")
|
||||
rootCmd.PersistentFlags().StringVarP(&conf.Endpoint, "endpoint", "e", "http://localhost:8080/api", "upload api endpoint url")
|
||||
rootCmd.PersistentFlags().StringVarP(&conf.Endpoint, "endpoint", "p", "http://localhost:8080/api", "upload api endpoint url")
|
||||
rootCmd.PersistentFlags().StringVarP(&conf.Expire, "expire", "e", "asap", "Expire setting: asap or duration (accepted shortcuts: dmh)")
|
||||
|
||||
err := rootCmd.Execute()
|
||||
if err != nil {
|
||||
|
||||
@@ -44,7 +44,7 @@ func Runclient(c *cfg.Config, args []string) error {
|
||||
|
||||
client.SetUserAgent("upctl-" + cfg.VERSION)
|
||||
|
||||
url := c.Endpoint + ApiVersion + "/file/put"
|
||||
url := c.Endpoint + ApiVersion + "/file/"
|
||||
|
||||
rq := client.R()
|
||||
for _, file := range args {
|
||||
@@ -92,7 +92,7 @@ func Runclient(c *cfg.Config, args []string) error {
|
||||
|
||||
resp, err := rq.
|
||||
SetFormData(map[string]string{
|
||||
"expire": "1d",
|
||||
"expire": c.Expire,
|
||||
}).
|
||||
SetUploadCallbackWithInterval(func(info req.UploadInfo) {
|
||||
fmt.Printf("\r%q uploaded %.2f%%", info.FileName, float64(info.UploadedSize)/float64(info.FileSize)*100.0)
|
||||
|
||||
Reference in New Issue
Block a user