efs-cli 1.0.5__tar.gz → 1.0.6__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: efs-cli
3
- Version: 1.0.5
3
+ Version: 1.0.6
4
4
  Summary: EepyFileServer API CLI written in Python
5
5
  Author: maxie
6
6
  License-Expression: MIT
@@ -0,0 +1,2 @@
1
+ __version__ = "1.0.6"
2
+
@@ -69,7 +69,7 @@ def remove(file_path, **__):
69
69
  print(f"Deleted {file_path}")
70
70
  else:
71
71
  print("Login using 'efs-cli auth <base url> <password>' to delete files")
72
- return 1
72
+ sys.exit(1)
73
73
 
74
74
  def ver(**__):
75
75
  conf = get_conf()
@@ -90,6 +90,21 @@ def instance(**__):
90
90
  print(f" Used : {disk_usage.human.used} Megabytes")
91
91
  print(f" Free : {disk_usage.human.free} Megabytes")
92
92
 
93
+ def url_for(file_path, public, check_if_exists, **__):
94
+ api = init_api()
95
+ if public:
96
+ api = api.public
97
+ if file_path.startswith("/public"):
98
+ file_path = file_path.removeprefix("/public")
99
+ try:
100
+ print(api.url_to_file(file_path, check_if_exists = check_if_exists))
101
+ except Exception as e:
102
+ print(e.args[0])
103
+ sys.exit(1)
104
+
105
+ def metadata(file_path):
106
+ ...
107
+
93
108
  def main():
94
109
  parser = ArgumentParser("efs-cli", description="eepyfileserver cli tool for downloading and uploading files")
95
110
  subparser = parser.add_subparsers()
@@ -111,13 +126,13 @@ def main():
111
126
  upload_parser = subparser.add_parser("upload", help="upload a file", aliases=["post", "up", "put"])
112
127
  upload_parser.add_argument("from_path", help="the local path of the file to upload")
113
128
  upload_parser.add_argument("to_path", help="the efs path to upload the file to")
114
- upload_parser.set_defaults(func=upload)
129
+ upload_parser.set_defaults(func=upload)
115
130
 
116
131
  list_files_parser = subparser.add_parser("list", help="list current files on efs", aliases=["ls", "files"])
117
132
  list_files_parser.set_defaults(func=list_files)
118
133
 
119
134
  remove_parser = subparser.add_parser("delete", help="delete a file", aliases=["remove", "rm"])
120
- remove_parser.add_argument("file_path")
135
+ remove_parser.add_argument("file_path", help="the efs file path to delete")
121
136
  remove_parser.set_defaults(func=remove)
122
137
 
123
138
  version_parser = subparser.add_parser("version", help="view efs-cli and dependencies versions", aliases=["ver"])
@@ -126,6 +141,12 @@ def main():
126
141
  instance_parser = subparser.add_parser("instance", help="view eepyfileserver instance info", aliases=["info"])
127
142
  instance_parser.set_defaults(func=instance)
128
143
 
144
+ urlfor_parser = subparser.add_parser("url-for", help="get the url for a file", aliases=["url"])
145
+ urlfor_parser.add_argument("file_path", help="the efs file path to return url for")
146
+ urlfor_parser.add_argument("-p", "--public", action="store_true", help="return public url if set to true")
147
+ urlfor_parser.add_argument("-c", "--check-if-exists", action="store_true", help="check if the file exists before returning the url")
148
+ urlfor_parser.set_defaults(func=url_for)
149
+
129
150
  args = parser.parse_args()
130
151
  if args == Namespace():
131
152
  args = parser.parse_args(["-h"])
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: efs-cli
3
- Version: 1.0.5
3
+ Version: 1.0.6
4
4
  Summary: EepyFileServer API CLI written in Python
5
5
  Author: maxie
6
6
  License-Expression: MIT
@@ -1,2 +0,0 @@
1
- __version__ = "1.0.5"
2
-
File without changes
File without changes
File without changes
File without changes