cloudsh 0.3.8__tar.gz → 0.3.9__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.
Files changed (58) hide show
  1. cloudsh-0.3.9/PKG-INFO +203 -0
  2. cloudsh-0.3.9/README.md +172 -0
  3. {cloudsh-0.3.8 → cloudsh-0.3.9}/cloudsh/utils.py +1 -1
  4. cloudsh-0.3.9/cloudsh.egg-info/PKG-INFO +203 -0
  5. cloudsh-0.3.9/cloudsh.egg-info/SOURCES.txt +53 -0
  6. cloudsh-0.3.9/cloudsh.egg-info/dependency_links.txt +1 -0
  7. cloudsh-0.3.9/cloudsh.egg-info/entry_points.txt +2 -0
  8. cloudsh-0.3.9/cloudsh.egg-info/requires.txt +26 -0
  9. cloudsh-0.3.9/cloudsh.egg-info/top_level.txt +1 -0
  10. cloudsh-0.3.9/pyproject.toml +66 -0
  11. cloudsh-0.3.9/setup.cfg +4 -0
  12. cloudsh-0.3.9/tests/test_cat.py +342 -0
  13. cloudsh-0.3.9/tests/test_complete.py +397 -0
  14. cloudsh-0.3.9/tests/test_cp.py +553 -0
  15. cloudsh-0.3.9/tests/test_head.py +626 -0
  16. cloudsh-0.3.9/tests/test_less.py +646 -0
  17. cloudsh-0.3.9/tests/test_ls.py +371 -0
  18. cloudsh-0.3.9/tests/test_main_module.py +80 -0
  19. cloudsh-0.3.9/tests/test_mkdir.py +148 -0
  20. cloudsh-0.3.9/tests/test_more.py +380 -0
  21. cloudsh-0.3.9/tests/test_mv.py +877 -0
  22. cloudsh-0.3.9/tests/test_rm.py +466 -0
  23. cloudsh-0.3.9/tests/test_sink.py +166 -0
  24. cloudsh-0.3.9/tests/test_tail.py +801 -0
  25. cloudsh-0.3.9/tests/test_touch.py +230 -0
  26. cloudsh-0.3.8/PKG-INFO +0 -30
  27. cloudsh-0.3.8/pyproject.toml +0 -62
  28. cloudsh-0.3.8/setup.py +0 -50
  29. {cloudsh-0.3.8 → cloudsh-0.3.9}/LICENSE +0 -0
  30. {cloudsh-0.3.8 → cloudsh-0.3.9}/cloudsh/__init__.py +0 -0
  31. {cloudsh-0.3.8 → cloudsh-0.3.9}/cloudsh/__main__.py +0 -0
  32. {cloudsh-0.3.8 → cloudsh-0.3.9}/cloudsh/args/cat.toml +0 -0
  33. {cloudsh-0.3.8 → cloudsh-0.3.9}/cloudsh/args/complete.toml +0 -0
  34. {cloudsh-0.3.8 → cloudsh-0.3.9}/cloudsh/args/cp.toml +0 -0
  35. {cloudsh-0.3.8 → cloudsh-0.3.9}/cloudsh/args/head.toml +0 -0
  36. {cloudsh-0.3.8 → cloudsh-0.3.9}/cloudsh/args/less.toml +0 -0
  37. {cloudsh-0.3.8 → cloudsh-0.3.9}/cloudsh/args/ls.toml +0 -0
  38. {cloudsh-0.3.8 → cloudsh-0.3.9}/cloudsh/args/mkdir.toml +0 -0
  39. {cloudsh-0.3.8 → cloudsh-0.3.9}/cloudsh/args/more.toml +0 -0
  40. {cloudsh-0.3.8 → cloudsh-0.3.9}/cloudsh/args/mv.toml +0 -0
  41. {cloudsh-0.3.8 → cloudsh-0.3.9}/cloudsh/args/rm.toml +0 -0
  42. {cloudsh-0.3.8 → cloudsh-0.3.9}/cloudsh/args/sink.toml +0 -0
  43. {cloudsh-0.3.8 → cloudsh-0.3.9}/cloudsh/args/tail.toml +0 -0
  44. {cloudsh-0.3.8 → cloudsh-0.3.9}/cloudsh/args/touch.toml +0 -0
  45. {cloudsh-0.3.8 → cloudsh-0.3.9}/cloudsh/commands/cat.py +0 -0
  46. {cloudsh-0.3.8 → cloudsh-0.3.9}/cloudsh/commands/complete.py +0 -0
  47. {cloudsh-0.3.8 → cloudsh-0.3.9}/cloudsh/commands/cp.py +0 -0
  48. {cloudsh-0.3.8 → cloudsh-0.3.9}/cloudsh/commands/head.py +0 -0
  49. {cloudsh-0.3.8 → cloudsh-0.3.9}/cloudsh/commands/less.py +0 -0
  50. {cloudsh-0.3.8 → cloudsh-0.3.9}/cloudsh/commands/ls.py +0 -0
  51. {cloudsh-0.3.8 → cloudsh-0.3.9}/cloudsh/commands/mkdir.py +0 -0
  52. {cloudsh-0.3.8 → cloudsh-0.3.9}/cloudsh/commands/more.py +0 -0
  53. {cloudsh-0.3.8 → cloudsh-0.3.9}/cloudsh/commands/mv.py +0 -0
  54. {cloudsh-0.3.8 → cloudsh-0.3.9}/cloudsh/commands/rm.py +0 -0
  55. {cloudsh-0.3.8 → cloudsh-0.3.9}/cloudsh/commands/sink.py +0 -0
  56. {cloudsh-0.3.8 → cloudsh-0.3.9}/cloudsh/commands/tail.py +0 -0
  57. {cloudsh-0.3.8 → cloudsh-0.3.9}/cloudsh/commands/touch.py +0 -0
  58. {cloudsh-0.3.8 → cloudsh-0.3.9}/cloudsh/main.py +0 -0
cloudsh-0.3.9/PKG-INFO ADDED
@@ -0,0 +1,203 @@
1
+ Metadata-Version: 2.4
2
+ Name: cloudsh
3
+ Version: 0.3.9
4
+ Summary: A Python CLI wrapping common Linux commands for local/cloud files.
5
+ Author-email: Your Name <you@example.com>
6
+ License-Expression: MIT
7
+ Requires-Python: >=3.9
8
+ Description-Content-Type: text/markdown
9
+ License-File: LICENSE
10
+ Requires-Dist: panpath<0.5,>=0.4.8
11
+ Requires-Dist: argx<0.5,>=0.4
12
+ Requires-Dist: python-simpleconf[toml]<0.10,>=0.9
13
+ Requires-Dist: aiofiles>=23.0.0
14
+ Requires-Dist: python-dateutil<3,>=2.9.0.post0
15
+ Requires-Dist: argcomplete<4,>=3.5.3
16
+ Provides-Extra: azure
17
+ Requires-Dist: azure-storage-blob<13,>=12; extra == "azure"
18
+ Provides-Extra: aws
19
+ Requires-Dist: aioboto3>=11.0.0; extra == "aws"
20
+ Provides-Extra: s3
21
+ Requires-Dist: aioboto3>=11.0.0; extra == "s3"
22
+ Provides-Extra: gs
23
+ Requires-Dist: gcloud-aio-storage>=9.5; extra == "gs"
24
+ Provides-Extra: gcs
25
+ Requires-Dist: gcloud-aio-storage>=9.5; extra == "gcs"
26
+ Provides-Extra: all
27
+ Requires-Dist: azure-storage-blob<13,>=12; extra == "all"
28
+ Requires-Dist: aioboto3>=11.0.0; extra == "all"
29
+ Requires-Dist: gcloud-aio-storage>=9.5; extra == "all"
30
+ Dynamic: license-file
31
+
32
+ # cloudsh
33
+
34
+ A Python CLI that wraps common Linux commands for both local and cloud files using [cloudpathlib](https://github.com/drivendataorg/cloudpathlib).
35
+
36
+ [![Pypi][1]][2] [![Github][3]][4] [![PythonVers][5]][6] ![Building][7] [![Codacy coverage][8]][9]
37
+
38
+ Cloud Storage Provider dependencies:
39
+
40
+ [![google-cloud-storage][10]][11] \
41
+ [![boto3][12]][13] \
42
+ [![azure-storage-blob][14]][15]
43
+
44
+ ## Installation
45
+
46
+ ```bash
47
+ pip install -U cloudsh
48
+
49
+ # Install for different cloud storage providers
50
+ pip install -U cloudsh[gcs] # Google Cloud Storage
51
+ pip install -U cloudsh[aws] # Amazon S3
52
+ pip install -U cloudsh[azure] # Azure Blob Storage
53
+
54
+ # Install for all cloud storage providers
55
+ pip install -U cloudsh[all]
56
+ ```
57
+
58
+ ## Usage
59
+
60
+ `cloudsh` provides common Linux commands that work with both local and cloud files. Currently supported commands include:
61
+
62
+ - `cat`: Concatenate and print files
63
+ - `cp`: Copy files and directories
64
+ - `head`: Output the first part of files
65
+ - `less`: Display file contents with forward and backward navigation
66
+ - `ls`: List directory contents
67
+ - `mkdir`: Make directories
68
+ - `more`: Display file contents page by page
69
+ - `mv`: Move files and directories
70
+ - `rm`: Remove files and directories
71
+ - `tail`: Output the last part of files
72
+ - `touch`: Create empty files
73
+
74
+ And two additional commands:
75
+
76
+ - `complete`: Generate shell completion scripts
77
+ - `sink`: Redirect output to a file
78
+
79
+ ### Authentication
80
+
81
+ See: https://cloudpathlib.drivendata.org/stable/authentication/ for details on how to authenticate with cloud storage providers.
82
+
83
+ ### The commands works on local files as the GNU/Linux commands do
84
+
85
+ ```bash
86
+ $ cloudsh ls /tmp
87
+ $ cloudsh cp /tmp/file.txt /tmp/file2.txt
88
+ ```
89
+
90
+ ### The commands works on cloud files
91
+
92
+ ```bash
93
+ $ cloudsh ls gs://my-bucket
94
+ $ cloudsh touch gs://my-bucket/file.txt
95
+ ```
96
+
97
+ ### The commands works between local and cloud files
98
+
99
+ ```bash
100
+ $ cloudsh cp /tmp/file.txt gs://my-bucket/file.txt
101
+ $ cloudsh mv gs://my-bucket/file.txt /tmp/file.txt
102
+ ```
103
+
104
+ ### The `sink` command redirects output to a file
105
+
106
+ ```bash
107
+ # It is easy to redirect output to a local file
108
+ $ echo "Hello, World!" > /tmp/hello.txt
109
+ # But it is not so easy to redirect output to a cloud file, so we use `sink`
110
+ $ echo "Hello, World!" | cloudsh sink gs://my-bucket/hello.txt
111
+ # Append to a cloud file
112
+ $ echo "Hello, World!" | cloudsh sink -a gs://my-bucket/hello.txt
113
+ ```
114
+
115
+ ## Drop-in Replacement for GNU/Linux Commands
116
+
117
+ Since the commands work on local files as well, you can make aliases to use `cloudsh` as a drop-in replacement for the GNU/Linux commands.
118
+
119
+ ```bash
120
+ alias cat='cloudsh cat'
121
+ alias cp='cloudsh cp'
122
+ alias head='cloudsh head'
123
+ alias ls='cloudsh ls'
124
+ alias mkdir='cloudsh mkdir'
125
+ alias mv='cloudsh mv'
126
+ alias rm='cloudsh rm'
127
+ alias tail='cloudsh tail'
128
+ alias touch='cloudsh touch'
129
+ ```
130
+
131
+ What if I want to use the original GNU/Linux commands?
132
+
133
+ ```bash
134
+ # alias ls='cloudsh ls'
135
+ ls -- -l # actually executes `/usr/bin/ls -l`
136
+ ```
137
+
138
+ ## Shell Completion
139
+
140
+ ### Generating Shell Completion Scripts
141
+
142
+ `cloudsh` provides shell completion support, including the subcommands, options and both local and cloud paths, for bash, zsh and fish. To enable it:
143
+
144
+ ```bash
145
+ # For bash
146
+ mkdir -p ~/.local/share/bash-completion
147
+ cloudsh complete --shell bash > ~/.local/share/bash-completion/cloudsh
148
+ activate-global-python-argcomplete --user
149
+ # Restart your shell
150
+ ```
151
+
152
+ ```bash
153
+ # For zsh
154
+ # Create the completions directory
155
+ mkdir -p ~/.zsh/completions
156
+
157
+ # Generate the Zsh script
158
+ cloudsh complete --shell zsh > ~/.zsh/completions/_cloudsh
159
+
160
+ # Update ~/.zshrc
161
+ echo 'fpath=(~/.zsh/completions $fpath)' >> ~/.zshrc
162
+ echo 'autoload -Uz compinit && compinit' >> ~/.zshrc
163
+
164
+ # Restart your shell
165
+ ```
166
+
167
+ ```bash
168
+ # For fish
169
+ cloudsh complete --shell fish > ~/.config/fish/completions/cloudsh.fish
170
+ ```
171
+
172
+ Because of the latency when completing cloud paths, a message 'fetching ...' will be shown when completing cloud paths. `export CLOUDSH_COMPLETE_NO_FETCHING_INDICATOR=1` to disable it.
173
+
174
+ ### Using a caching file for the completion to avoid latency when completing cloud paths
175
+
176
+ ```bash
177
+ # Only cache the paths at depth 2 in the bucket
178
+ cloudsh complete --update-cache --depth 2 gs://my-bucket
179
+ ```
180
+
181
+ > [!NOTE]
182
+ > Remember to update the cache when the bucket structure changes.
183
+ > You can set up a cron job to update the cache periodically.
184
+
185
+ > [!TIP]
186
+ > For the first time you are using cached cloud path completion, a warning message will be shown to remind you that you are using a cached completion. The warning will only be shown when `<tmpdir>/cloudsh_caching_warned` does not exist, which will be created after the first warning. To disable the warning permanently, try `export CLOUDSH_COMPLETE_CACHING_WARN=1`.
187
+
188
+
189
+ [1]: https://img.shields.io/pypi/v/cloudsh?style=flat-square
190
+ [2]: https://pypi.org/project/cloudsh/
191
+ [3]: https://img.shields.io/github/v/tag/pwwang/cloudsh?style=flat-square
192
+ [4]: https://github.com/pwwang/cloudsh/
193
+ [5]: https://img.shields.io/pypi/pyversions/cloudsh?style=flat-square
194
+ [6]: https://pypi.org/project/cloudsh/
195
+ [7]: https://img.shields.io/github/actions/workflow/status/pwwang/cloudsh/build.yml
196
+ [8]: https://img.shields.io/codacy/coverage/bb84185297244aefa6de4d675206a1cf?style=flat-square
197
+ [9]: https://app.codacy.com/gh/pwwang/cloudsh/dashboard
198
+ [10]: https://img.shields.io/badge/dynamic/toml?url=https%3A%2F%2Fraw.githubusercontent.com%2Fpwwang%2Fcloudsh%2Fmaster%2Fpyproject.toml&query=%24.%22project.optional-dependencies%22.gcs%5B0%5D&prefix=requires%3A&style=flat-square&label=gcloud-aio-storage
199
+ [11]: https://googleapis.dev/python/storage/latest/index.html
200
+ [12]: https://img.shields.io/badge/dynamic/toml?url=https%3A%2F%2Fraw.githubusercontent.com%2Fpwwang%2Fcloudsh%2Fmaster%2Fpyproject.toml&query=%24.%22project.optional-dependencies%22.aws%5B0%5D&prefix=requires%3A&style=flat-square&label=aioboto3
201
+ [13]: https://pypi.org/project/boto3/
202
+ [14]: https://img.shields.io/badge/dynamic/toml?url=https%3A%2F%2Fraw.githubusercontent.com%2Fpwwang%2Fcloudsh%2Fmaster%2Fpyproject.toml&query=%24.%22project.optional-dependencies%22.azure%5B0%5D&prefix=requires%3A&style=flat-square&label=azure-storage-blob
203
+ [15]: https://pypi.org/project/azure-storage-blob/
@@ -0,0 +1,172 @@
1
+ # cloudsh
2
+
3
+ A Python CLI that wraps common Linux commands for both local and cloud files using [cloudpathlib](https://github.com/drivendataorg/cloudpathlib).
4
+
5
+ [![Pypi][1]][2] [![Github][3]][4] [![PythonVers][5]][6] ![Building][7] [![Codacy coverage][8]][9]
6
+
7
+ Cloud Storage Provider dependencies:
8
+
9
+ [![google-cloud-storage][10]][11] \
10
+ [![boto3][12]][13] \
11
+ [![azure-storage-blob][14]][15]
12
+
13
+ ## Installation
14
+
15
+ ```bash
16
+ pip install -U cloudsh
17
+
18
+ # Install for different cloud storage providers
19
+ pip install -U cloudsh[gcs] # Google Cloud Storage
20
+ pip install -U cloudsh[aws] # Amazon S3
21
+ pip install -U cloudsh[azure] # Azure Blob Storage
22
+
23
+ # Install for all cloud storage providers
24
+ pip install -U cloudsh[all]
25
+ ```
26
+
27
+ ## Usage
28
+
29
+ `cloudsh` provides common Linux commands that work with both local and cloud files. Currently supported commands include:
30
+
31
+ - `cat`: Concatenate and print files
32
+ - `cp`: Copy files and directories
33
+ - `head`: Output the first part of files
34
+ - `less`: Display file contents with forward and backward navigation
35
+ - `ls`: List directory contents
36
+ - `mkdir`: Make directories
37
+ - `more`: Display file contents page by page
38
+ - `mv`: Move files and directories
39
+ - `rm`: Remove files and directories
40
+ - `tail`: Output the last part of files
41
+ - `touch`: Create empty files
42
+
43
+ And two additional commands:
44
+
45
+ - `complete`: Generate shell completion scripts
46
+ - `sink`: Redirect output to a file
47
+
48
+ ### Authentication
49
+
50
+ See: https://cloudpathlib.drivendata.org/stable/authentication/ for details on how to authenticate with cloud storage providers.
51
+
52
+ ### The commands works on local files as the GNU/Linux commands do
53
+
54
+ ```bash
55
+ $ cloudsh ls /tmp
56
+ $ cloudsh cp /tmp/file.txt /tmp/file2.txt
57
+ ```
58
+
59
+ ### The commands works on cloud files
60
+
61
+ ```bash
62
+ $ cloudsh ls gs://my-bucket
63
+ $ cloudsh touch gs://my-bucket/file.txt
64
+ ```
65
+
66
+ ### The commands works between local and cloud files
67
+
68
+ ```bash
69
+ $ cloudsh cp /tmp/file.txt gs://my-bucket/file.txt
70
+ $ cloudsh mv gs://my-bucket/file.txt /tmp/file.txt
71
+ ```
72
+
73
+ ### The `sink` command redirects output to a file
74
+
75
+ ```bash
76
+ # It is easy to redirect output to a local file
77
+ $ echo "Hello, World!" > /tmp/hello.txt
78
+ # But it is not so easy to redirect output to a cloud file, so we use `sink`
79
+ $ echo "Hello, World!" | cloudsh sink gs://my-bucket/hello.txt
80
+ # Append to a cloud file
81
+ $ echo "Hello, World!" | cloudsh sink -a gs://my-bucket/hello.txt
82
+ ```
83
+
84
+ ## Drop-in Replacement for GNU/Linux Commands
85
+
86
+ Since the commands work on local files as well, you can make aliases to use `cloudsh` as a drop-in replacement for the GNU/Linux commands.
87
+
88
+ ```bash
89
+ alias cat='cloudsh cat'
90
+ alias cp='cloudsh cp'
91
+ alias head='cloudsh head'
92
+ alias ls='cloudsh ls'
93
+ alias mkdir='cloudsh mkdir'
94
+ alias mv='cloudsh mv'
95
+ alias rm='cloudsh rm'
96
+ alias tail='cloudsh tail'
97
+ alias touch='cloudsh touch'
98
+ ```
99
+
100
+ What if I want to use the original GNU/Linux commands?
101
+
102
+ ```bash
103
+ # alias ls='cloudsh ls'
104
+ ls -- -l # actually executes `/usr/bin/ls -l`
105
+ ```
106
+
107
+ ## Shell Completion
108
+
109
+ ### Generating Shell Completion Scripts
110
+
111
+ `cloudsh` provides shell completion support, including the subcommands, options and both local and cloud paths, for bash, zsh and fish. To enable it:
112
+
113
+ ```bash
114
+ # For bash
115
+ mkdir -p ~/.local/share/bash-completion
116
+ cloudsh complete --shell bash > ~/.local/share/bash-completion/cloudsh
117
+ activate-global-python-argcomplete --user
118
+ # Restart your shell
119
+ ```
120
+
121
+ ```bash
122
+ # For zsh
123
+ # Create the completions directory
124
+ mkdir -p ~/.zsh/completions
125
+
126
+ # Generate the Zsh script
127
+ cloudsh complete --shell zsh > ~/.zsh/completions/_cloudsh
128
+
129
+ # Update ~/.zshrc
130
+ echo 'fpath=(~/.zsh/completions $fpath)' >> ~/.zshrc
131
+ echo 'autoload -Uz compinit && compinit' >> ~/.zshrc
132
+
133
+ # Restart your shell
134
+ ```
135
+
136
+ ```bash
137
+ # For fish
138
+ cloudsh complete --shell fish > ~/.config/fish/completions/cloudsh.fish
139
+ ```
140
+
141
+ Because of the latency when completing cloud paths, a message 'fetching ...' will be shown when completing cloud paths. `export CLOUDSH_COMPLETE_NO_FETCHING_INDICATOR=1` to disable it.
142
+
143
+ ### Using a caching file for the completion to avoid latency when completing cloud paths
144
+
145
+ ```bash
146
+ # Only cache the paths at depth 2 in the bucket
147
+ cloudsh complete --update-cache --depth 2 gs://my-bucket
148
+ ```
149
+
150
+ > [!NOTE]
151
+ > Remember to update the cache when the bucket structure changes.
152
+ > You can set up a cron job to update the cache periodically.
153
+
154
+ > [!TIP]
155
+ > For the first time you are using cached cloud path completion, a warning message will be shown to remind you that you are using a cached completion. The warning will only be shown when `<tmpdir>/cloudsh_caching_warned` does not exist, which will be created after the first warning. To disable the warning permanently, try `export CLOUDSH_COMPLETE_CACHING_WARN=1`.
156
+
157
+
158
+ [1]: https://img.shields.io/pypi/v/cloudsh?style=flat-square
159
+ [2]: https://pypi.org/project/cloudsh/
160
+ [3]: https://img.shields.io/github/v/tag/pwwang/cloudsh?style=flat-square
161
+ [4]: https://github.com/pwwang/cloudsh/
162
+ [5]: https://img.shields.io/pypi/pyversions/cloudsh?style=flat-square
163
+ [6]: https://pypi.org/project/cloudsh/
164
+ [7]: https://img.shields.io/github/actions/workflow/status/pwwang/cloudsh/build.yml
165
+ [8]: https://img.shields.io/codacy/coverage/bb84185297244aefa6de4d675206a1cf?style=flat-square
166
+ [9]: https://app.codacy.com/gh/pwwang/cloudsh/dashboard
167
+ [10]: https://img.shields.io/badge/dynamic/toml?url=https%3A%2F%2Fraw.githubusercontent.com%2Fpwwang%2Fcloudsh%2Fmaster%2Fpyproject.toml&query=%24.%22project.optional-dependencies%22.gcs%5B0%5D&prefix=requires%3A&style=flat-square&label=gcloud-aio-storage
168
+ [11]: https://googleapis.dev/python/storage/latest/index.html
169
+ [12]: https://img.shields.io/badge/dynamic/toml?url=https%3A%2F%2Fraw.githubusercontent.com%2Fpwwang%2Fcloudsh%2Fmaster%2Fpyproject.toml&query=%24.%22project.optional-dependencies%22.aws%5B0%5D&prefix=requires%3A&style=flat-square&label=aioboto3
170
+ [13]: https://pypi.org/project/boto3/
171
+ [14]: https://img.shields.io/badge/dynamic/toml?url=https%3A%2F%2Fraw.githubusercontent.com%2Fpwwang%2Fcloudsh%2Fmaster%2Fpyproject.toml&query=%24.%22project.optional-dependencies%22.azure%5B0%5D&prefix=requires%3A&style=flat-square&label=azure-storage-blob
172
+ [15]: https://pypi.org/project/azure-storage-blob/
@@ -1,4 +1,4 @@
1
- __version__ = "0.3.8"
1
+ __version__ = "0.3.9"
2
2
 
3
3
  PACKAGE = "cloudsh"
4
4
  MULTIPLIERS = {
@@ -0,0 +1,203 @@
1
+ Metadata-Version: 2.4
2
+ Name: cloudsh
3
+ Version: 0.3.9
4
+ Summary: A Python CLI wrapping common Linux commands for local/cloud files.
5
+ Author-email: Your Name <you@example.com>
6
+ License-Expression: MIT
7
+ Requires-Python: >=3.9
8
+ Description-Content-Type: text/markdown
9
+ License-File: LICENSE
10
+ Requires-Dist: panpath<0.5,>=0.4.8
11
+ Requires-Dist: argx<0.5,>=0.4
12
+ Requires-Dist: python-simpleconf[toml]<0.10,>=0.9
13
+ Requires-Dist: aiofiles>=23.0.0
14
+ Requires-Dist: python-dateutil<3,>=2.9.0.post0
15
+ Requires-Dist: argcomplete<4,>=3.5.3
16
+ Provides-Extra: azure
17
+ Requires-Dist: azure-storage-blob<13,>=12; extra == "azure"
18
+ Provides-Extra: aws
19
+ Requires-Dist: aioboto3>=11.0.0; extra == "aws"
20
+ Provides-Extra: s3
21
+ Requires-Dist: aioboto3>=11.0.0; extra == "s3"
22
+ Provides-Extra: gs
23
+ Requires-Dist: gcloud-aio-storage>=9.5; extra == "gs"
24
+ Provides-Extra: gcs
25
+ Requires-Dist: gcloud-aio-storage>=9.5; extra == "gcs"
26
+ Provides-Extra: all
27
+ Requires-Dist: azure-storage-blob<13,>=12; extra == "all"
28
+ Requires-Dist: aioboto3>=11.0.0; extra == "all"
29
+ Requires-Dist: gcloud-aio-storage>=9.5; extra == "all"
30
+ Dynamic: license-file
31
+
32
+ # cloudsh
33
+
34
+ A Python CLI that wraps common Linux commands for both local and cloud files using [cloudpathlib](https://github.com/drivendataorg/cloudpathlib).
35
+
36
+ [![Pypi][1]][2] [![Github][3]][4] [![PythonVers][5]][6] ![Building][7] [![Codacy coverage][8]][9]
37
+
38
+ Cloud Storage Provider dependencies:
39
+
40
+ [![google-cloud-storage][10]][11] \
41
+ [![boto3][12]][13] \
42
+ [![azure-storage-blob][14]][15]
43
+
44
+ ## Installation
45
+
46
+ ```bash
47
+ pip install -U cloudsh
48
+
49
+ # Install for different cloud storage providers
50
+ pip install -U cloudsh[gcs] # Google Cloud Storage
51
+ pip install -U cloudsh[aws] # Amazon S3
52
+ pip install -U cloudsh[azure] # Azure Blob Storage
53
+
54
+ # Install for all cloud storage providers
55
+ pip install -U cloudsh[all]
56
+ ```
57
+
58
+ ## Usage
59
+
60
+ `cloudsh` provides common Linux commands that work with both local and cloud files. Currently supported commands include:
61
+
62
+ - `cat`: Concatenate and print files
63
+ - `cp`: Copy files and directories
64
+ - `head`: Output the first part of files
65
+ - `less`: Display file contents with forward and backward navigation
66
+ - `ls`: List directory contents
67
+ - `mkdir`: Make directories
68
+ - `more`: Display file contents page by page
69
+ - `mv`: Move files and directories
70
+ - `rm`: Remove files and directories
71
+ - `tail`: Output the last part of files
72
+ - `touch`: Create empty files
73
+
74
+ And two additional commands:
75
+
76
+ - `complete`: Generate shell completion scripts
77
+ - `sink`: Redirect output to a file
78
+
79
+ ### Authentication
80
+
81
+ See: https://cloudpathlib.drivendata.org/stable/authentication/ for details on how to authenticate with cloud storage providers.
82
+
83
+ ### The commands works on local files as the GNU/Linux commands do
84
+
85
+ ```bash
86
+ $ cloudsh ls /tmp
87
+ $ cloudsh cp /tmp/file.txt /tmp/file2.txt
88
+ ```
89
+
90
+ ### The commands works on cloud files
91
+
92
+ ```bash
93
+ $ cloudsh ls gs://my-bucket
94
+ $ cloudsh touch gs://my-bucket/file.txt
95
+ ```
96
+
97
+ ### The commands works between local and cloud files
98
+
99
+ ```bash
100
+ $ cloudsh cp /tmp/file.txt gs://my-bucket/file.txt
101
+ $ cloudsh mv gs://my-bucket/file.txt /tmp/file.txt
102
+ ```
103
+
104
+ ### The `sink` command redirects output to a file
105
+
106
+ ```bash
107
+ # It is easy to redirect output to a local file
108
+ $ echo "Hello, World!" > /tmp/hello.txt
109
+ # But it is not so easy to redirect output to a cloud file, so we use `sink`
110
+ $ echo "Hello, World!" | cloudsh sink gs://my-bucket/hello.txt
111
+ # Append to a cloud file
112
+ $ echo "Hello, World!" | cloudsh sink -a gs://my-bucket/hello.txt
113
+ ```
114
+
115
+ ## Drop-in Replacement for GNU/Linux Commands
116
+
117
+ Since the commands work on local files as well, you can make aliases to use `cloudsh` as a drop-in replacement for the GNU/Linux commands.
118
+
119
+ ```bash
120
+ alias cat='cloudsh cat'
121
+ alias cp='cloudsh cp'
122
+ alias head='cloudsh head'
123
+ alias ls='cloudsh ls'
124
+ alias mkdir='cloudsh mkdir'
125
+ alias mv='cloudsh mv'
126
+ alias rm='cloudsh rm'
127
+ alias tail='cloudsh tail'
128
+ alias touch='cloudsh touch'
129
+ ```
130
+
131
+ What if I want to use the original GNU/Linux commands?
132
+
133
+ ```bash
134
+ # alias ls='cloudsh ls'
135
+ ls -- -l # actually executes `/usr/bin/ls -l`
136
+ ```
137
+
138
+ ## Shell Completion
139
+
140
+ ### Generating Shell Completion Scripts
141
+
142
+ `cloudsh` provides shell completion support, including the subcommands, options and both local and cloud paths, for bash, zsh and fish. To enable it:
143
+
144
+ ```bash
145
+ # For bash
146
+ mkdir -p ~/.local/share/bash-completion
147
+ cloudsh complete --shell bash > ~/.local/share/bash-completion/cloudsh
148
+ activate-global-python-argcomplete --user
149
+ # Restart your shell
150
+ ```
151
+
152
+ ```bash
153
+ # For zsh
154
+ # Create the completions directory
155
+ mkdir -p ~/.zsh/completions
156
+
157
+ # Generate the Zsh script
158
+ cloudsh complete --shell zsh > ~/.zsh/completions/_cloudsh
159
+
160
+ # Update ~/.zshrc
161
+ echo 'fpath=(~/.zsh/completions $fpath)' >> ~/.zshrc
162
+ echo 'autoload -Uz compinit && compinit' >> ~/.zshrc
163
+
164
+ # Restart your shell
165
+ ```
166
+
167
+ ```bash
168
+ # For fish
169
+ cloudsh complete --shell fish > ~/.config/fish/completions/cloudsh.fish
170
+ ```
171
+
172
+ Because of the latency when completing cloud paths, a message 'fetching ...' will be shown when completing cloud paths. `export CLOUDSH_COMPLETE_NO_FETCHING_INDICATOR=1` to disable it.
173
+
174
+ ### Using a caching file for the completion to avoid latency when completing cloud paths
175
+
176
+ ```bash
177
+ # Only cache the paths at depth 2 in the bucket
178
+ cloudsh complete --update-cache --depth 2 gs://my-bucket
179
+ ```
180
+
181
+ > [!NOTE]
182
+ > Remember to update the cache when the bucket structure changes.
183
+ > You can set up a cron job to update the cache periodically.
184
+
185
+ > [!TIP]
186
+ > For the first time you are using cached cloud path completion, a warning message will be shown to remind you that you are using a cached completion. The warning will only be shown when `<tmpdir>/cloudsh_caching_warned` does not exist, which will be created after the first warning. To disable the warning permanently, try `export CLOUDSH_COMPLETE_CACHING_WARN=1`.
187
+
188
+
189
+ [1]: https://img.shields.io/pypi/v/cloudsh?style=flat-square
190
+ [2]: https://pypi.org/project/cloudsh/
191
+ [3]: https://img.shields.io/github/v/tag/pwwang/cloudsh?style=flat-square
192
+ [4]: https://github.com/pwwang/cloudsh/
193
+ [5]: https://img.shields.io/pypi/pyversions/cloudsh?style=flat-square
194
+ [6]: https://pypi.org/project/cloudsh/
195
+ [7]: https://img.shields.io/github/actions/workflow/status/pwwang/cloudsh/build.yml
196
+ [8]: https://img.shields.io/codacy/coverage/bb84185297244aefa6de4d675206a1cf?style=flat-square
197
+ [9]: https://app.codacy.com/gh/pwwang/cloudsh/dashboard
198
+ [10]: https://img.shields.io/badge/dynamic/toml?url=https%3A%2F%2Fraw.githubusercontent.com%2Fpwwang%2Fcloudsh%2Fmaster%2Fpyproject.toml&query=%24.%22project.optional-dependencies%22.gcs%5B0%5D&prefix=requires%3A&style=flat-square&label=gcloud-aio-storage
199
+ [11]: https://googleapis.dev/python/storage/latest/index.html
200
+ [12]: https://img.shields.io/badge/dynamic/toml?url=https%3A%2F%2Fraw.githubusercontent.com%2Fpwwang%2Fcloudsh%2Fmaster%2Fpyproject.toml&query=%24.%22project.optional-dependencies%22.aws%5B0%5D&prefix=requires%3A&style=flat-square&label=aioboto3
201
+ [13]: https://pypi.org/project/boto3/
202
+ [14]: https://img.shields.io/badge/dynamic/toml?url=https%3A%2F%2Fraw.githubusercontent.com%2Fpwwang%2Fcloudsh%2Fmaster%2Fpyproject.toml&query=%24.%22project.optional-dependencies%22.azure%5B0%5D&prefix=requires%3A&style=flat-square&label=azure-storage-blob
203
+ [15]: https://pypi.org/project/azure-storage-blob/
@@ -0,0 +1,53 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ cloudsh/__init__.py
5
+ cloudsh/__main__.py
6
+ cloudsh/main.py
7
+ cloudsh/utils.py
8
+ cloudsh.egg-info/PKG-INFO
9
+ cloudsh.egg-info/SOURCES.txt
10
+ cloudsh.egg-info/dependency_links.txt
11
+ cloudsh.egg-info/entry_points.txt
12
+ cloudsh.egg-info/requires.txt
13
+ cloudsh.egg-info/top_level.txt
14
+ cloudsh/args/cat.toml
15
+ cloudsh/args/complete.toml
16
+ cloudsh/args/cp.toml
17
+ cloudsh/args/head.toml
18
+ cloudsh/args/less.toml
19
+ cloudsh/args/ls.toml
20
+ cloudsh/args/mkdir.toml
21
+ cloudsh/args/more.toml
22
+ cloudsh/args/mv.toml
23
+ cloudsh/args/rm.toml
24
+ cloudsh/args/sink.toml
25
+ cloudsh/args/tail.toml
26
+ cloudsh/args/touch.toml
27
+ cloudsh/commands/cat.py
28
+ cloudsh/commands/complete.py
29
+ cloudsh/commands/cp.py
30
+ cloudsh/commands/head.py
31
+ cloudsh/commands/less.py
32
+ cloudsh/commands/ls.py
33
+ cloudsh/commands/mkdir.py
34
+ cloudsh/commands/more.py
35
+ cloudsh/commands/mv.py
36
+ cloudsh/commands/rm.py
37
+ cloudsh/commands/sink.py
38
+ cloudsh/commands/tail.py
39
+ cloudsh/commands/touch.py
40
+ tests/test_cat.py
41
+ tests/test_complete.py
42
+ tests/test_cp.py
43
+ tests/test_head.py
44
+ tests/test_less.py
45
+ tests/test_ls.py
46
+ tests/test_main_module.py
47
+ tests/test_mkdir.py
48
+ tests/test_more.py
49
+ tests/test_mv.py
50
+ tests/test_rm.py
51
+ tests/test_sink.py
52
+ tests/test_tail.py
53
+ tests/test_touch.py
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ cloudsh = cloudsh.main:main
@@ -0,0 +1,26 @@
1
+ panpath<0.5,>=0.4.8
2
+ argx<0.5,>=0.4
3
+ python-simpleconf[toml]<0.10,>=0.9
4
+ aiofiles>=23.0.0
5
+ python-dateutil<3,>=2.9.0.post0
6
+ argcomplete<4,>=3.5.3
7
+
8
+ [all]
9
+ azure-storage-blob<13,>=12
10
+ aioboto3>=11.0.0
11
+ gcloud-aio-storage>=9.5
12
+
13
+ [aws]
14
+ aioboto3>=11.0.0
15
+
16
+ [azure]
17
+ azure-storage-blob<13,>=12
18
+
19
+ [gcs]
20
+ gcloud-aio-storage>=9.5
21
+
22
+ [gs]
23
+ gcloud-aio-storage>=9.5
24
+
25
+ [s3]
26
+ aioboto3>=11.0.0
@@ -0,0 +1 @@
1
+ cloudsh