options.go 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // Copyright 2019 Yunion
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. package main
  15. import (
  16. "os"
  17. "yunion.io/x/log"
  18. "yunion.io/x/structarg"
  19. )
  20. const BLOCK_SIZE = 8
  21. type Options struct {
  22. Url string `help:"destination to fetch content" required:"true"`
  23. Tmpdir string `help:"temporary dir save fs content" required:"true"`
  24. Token string `help:"authentication information to access given url" required:"true"`
  25. Blocksize int `help:"block size of content file system(MB)"`
  26. MountPoint string `help:"mount path of fuse fs" required:"true"`
  27. Debug bool `help:"enable debug go fuse"`
  28. Foreground bool `help:"run in foreground"`
  29. // image encrypt info
  30. EncryptAlg string `help:"image encrypt alg"`
  31. EncryptKey string `help:"image encrypt password"`
  32. }
  33. var opt = &Options{}
  34. func init() {
  35. // structarg.NewArgumentParser(&BaseOptions{}
  36. parser, err := structarg.NewArgumentParser(opt, "", "", "")
  37. if err != nil {
  38. log.Fatalf("Error define argument parser: %v", err)
  39. }
  40. err = parser.ParseArgs2(os.Args[1:], true, true)
  41. if err != nil {
  42. log.Fatalf("Failed parse args %s", err)
  43. }
  44. log.Errorf("%v", opt)
  45. if opt.Blocksize <= 0 {
  46. opt.Blocksize = BLOCK_SIZE
  47. }
  48. }