linux-command 0.0.1__tar.gz → 0.2.0__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.
- {linux-command-0.0.1 → linux-command-0.2.0}/PKG-INFO +33 -14
- {linux-command-0.0.1 → linux-command-0.2.0}/README.md +32 -13
- {linux-command-0.0.1 → linux-command-0.2.0}/linux_command/linux_command.py +46 -13
- {linux-command-0.0.1 → linux-command-0.2.0}/linux_command.egg-info/PKG-INFO +33 -14
- {linux-command-0.0.1 → linux-command-0.2.0}/linux_command/__init__.py +0 -0
- {linux-command-0.0.1 → linux-command-0.2.0}/linux_command.egg-info/SOURCES.txt +0 -0
- {linux-command-0.0.1 → linux-command-0.2.0}/linux_command.egg-info/dependency_links.txt +0 -0
- {linux-command-0.0.1 → linux-command-0.2.0}/linux_command.egg-info/entry_points.txt +0 -0
- {linux-command-0.0.1 → linux-command-0.2.0}/linux_command.egg-info/top_level.txt +0 -0
- {linux-command-0.0.1 → linux-command-0.2.0}/setup.cfg +0 -0
- {linux-command-0.0.1 → linux-command-0.2.0}/setup.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: linux-command
|
|
3
|
-
Version: 0.0
|
|
3
|
+
Version: 0.2.0
|
|
4
4
|
Summary: A command line tool to perform custom tasks.
|
|
5
5
|
Home-page: https://github.com/MouxiaoHuang/linux-command
|
|
6
6
|
Author: Mouxiao Huang
|
|
@@ -192,32 +192,37 @@ cmd grep "search_term" /path/to/file
|
|
|
192
192
|
|
|
193
193
|
---
|
|
194
194
|
|
|
195
|
-
### 26. `tar-compress [source] [output]` - Compress
|
|
196
|
-
|
|
197
|
-
- For `.tar.gz`:
|
|
195
|
+
### 26. `tar-compress [source directory] [output file] [--exclude file_or_directory ...]` - Compress directories into `.tar` or `.tar.gz` while excluding specific files or folders
|
|
198
196
|
|
|
199
197
|
```bash
|
|
200
|
-
cmd tar-compress /path/to/source
|
|
198
|
+
cmd tar-compress /path/to/source /path/to/output.tar.gz --exclude node_modules --exclude .git
|
|
201
199
|
```
|
|
200
|
+
This command will compress `/path/to/source` into `/path/to/output.tar.gz` and exclude the `node_modules` and `.git` directories.
|
|
201
|
+
|
|
202
|
+
### 27. `tar-extract [source] [destination directory]` - Extract a single file or all `.tar`/`.tar.gz` files from a specified directory
|
|
202
203
|
|
|
203
|
-
-
|
|
204
|
+
- To extract a single `.tar` or `.tar.gz` file:
|
|
204
205
|
|
|
205
206
|
```bash
|
|
206
|
-
cmd tar-
|
|
207
|
+
cmd tar-extract /path/to/archive.tar.gz /path/to/destination
|
|
207
208
|
```
|
|
208
209
|
|
|
209
|
-
|
|
210
|
+
- To extract all `.tar` and `.tar.gz` files within a directory (default: all):
|
|
211
|
+
|
|
212
|
+
```bash
|
|
213
|
+
cmd tar-extract /path/to/directory /path/to/destination all
|
|
214
|
+
```
|
|
210
215
|
|
|
211
|
-
-
|
|
216
|
+
- To extract all `.tar` files within a directory:
|
|
212
217
|
|
|
213
218
|
```bash
|
|
214
|
-
cmd tar-extract
|
|
219
|
+
cmd tar-extract /path/to/directory /destination/path tar
|
|
215
220
|
```
|
|
216
221
|
|
|
217
|
-
-
|
|
222
|
+
- To extract all `.tar.gz` files within a directory:
|
|
218
223
|
|
|
219
224
|
```bash
|
|
220
|
-
cmd tar-extract
|
|
225
|
+
cmd tar-extract /path/to/directory /destination/path gz
|
|
221
226
|
```
|
|
222
227
|
|
|
223
228
|
### 28. `tar-list [archive]` - List contents of a `.tar` or `.tar.gz` archive
|
|
@@ -228,10 +233,26 @@ cmd tar-list archive.tar.gz
|
|
|
228
233
|
|
|
229
234
|
### 29. `tar-add [file] [archive]` - Add a file to an existing `.tar` archive
|
|
230
235
|
|
|
236
|
+
---
|
|
237
|
+
|
|
231
238
|
```bash
|
|
232
239
|
cmd tar-add newfile.txt archive.tar
|
|
233
240
|
```
|
|
234
241
|
|
|
242
|
+
### 30. `unzip-all [source directory] [target directory]` - Extract all `.zip` files found in a specified directory into a target directory
|
|
243
|
+
|
|
244
|
+
```bash
|
|
245
|
+
cmd unzip-all /path/to/zips /path/to/extract
|
|
246
|
+
```
|
|
247
|
+
This command will find all `.zip` files in `/path/to/zips` and extract each into `/path/to/extract`.
|
|
248
|
+
|
|
249
|
+
### 31. `zip-compress [output file.zip] [directory or file ...]` - Create a `.zip` file that includes multiple specified directories or files
|
|
250
|
+
|
|
251
|
+
```bash
|
|
252
|
+
cmd zip-compress /path/to/output.zip /path/to/dir1 /path/to/dir2
|
|
253
|
+
```
|
|
254
|
+
This command will create a `.zip` file at `/path/to/output.zip` that contains everything in `/path/to/dir1` and `/path/to/dir2`.
|
|
255
|
+
|
|
235
256
|
---
|
|
236
257
|
|
|
237
258
|
## Contributing
|
|
@@ -253,5 +274,3 @@ Thank you for your interest in contributing to `linux-command`! Your contributio
|
|
|
253
274
|
## License
|
|
254
275
|
|
|
255
276
|
This project is licensed under the MIT License.
|
|
256
|
-
|
|
257
|
-
To encourage contributions and pull requests from the community, you can add a section to your `README.md` that welcomes contributions. This section typically explains how people can contribute to the project, submit issues, and make pull requests. It’s also a good idea to outline some basic guidelines for contributing (e.g., coding style, creating issues before pull requests).
|
|
@@ -179,32 +179,37 @@ cmd grep "search_term" /path/to/file
|
|
|
179
179
|
|
|
180
180
|
---
|
|
181
181
|
|
|
182
|
-
### 26. `tar-compress [source] [output]` - Compress
|
|
183
|
-
|
|
184
|
-
- For `.tar.gz`:
|
|
182
|
+
### 26. `tar-compress [source directory] [output file] [--exclude file_or_directory ...]` - Compress directories into `.tar` or `.tar.gz` while excluding specific files or folders
|
|
185
183
|
|
|
186
184
|
```bash
|
|
187
|
-
cmd tar-compress /path/to/source
|
|
185
|
+
cmd tar-compress /path/to/source /path/to/output.tar.gz --exclude node_modules --exclude .git
|
|
188
186
|
```
|
|
187
|
+
This command will compress `/path/to/source` into `/path/to/output.tar.gz` and exclude the `node_modules` and `.git` directories.
|
|
188
|
+
|
|
189
|
+
### 27. `tar-extract [source] [destination directory]` - Extract a single file or all `.tar`/`.tar.gz` files from a specified directory
|
|
189
190
|
|
|
190
|
-
-
|
|
191
|
+
- To extract a single `.tar` or `.tar.gz` file:
|
|
191
192
|
|
|
192
193
|
```bash
|
|
193
|
-
cmd tar-
|
|
194
|
+
cmd tar-extract /path/to/archive.tar.gz /path/to/destination
|
|
194
195
|
```
|
|
195
196
|
|
|
196
|
-
|
|
197
|
+
- To extract all `.tar` and `.tar.gz` files within a directory (default: all):
|
|
198
|
+
|
|
199
|
+
```bash
|
|
200
|
+
cmd tar-extract /path/to/directory /path/to/destination all
|
|
201
|
+
```
|
|
197
202
|
|
|
198
|
-
-
|
|
203
|
+
- To extract all `.tar` files within a directory:
|
|
199
204
|
|
|
200
205
|
```bash
|
|
201
|
-
cmd tar-extract
|
|
206
|
+
cmd tar-extract /path/to/directory /destination/path tar
|
|
202
207
|
```
|
|
203
208
|
|
|
204
|
-
-
|
|
209
|
+
- To extract all `.tar.gz` files within a directory:
|
|
205
210
|
|
|
206
211
|
```bash
|
|
207
|
-
cmd tar-extract
|
|
212
|
+
cmd tar-extract /path/to/directory /destination/path gz
|
|
208
213
|
```
|
|
209
214
|
|
|
210
215
|
### 28. `tar-list [archive]` - List contents of a `.tar` or `.tar.gz` archive
|
|
@@ -215,10 +220,26 @@ cmd tar-list archive.tar.gz
|
|
|
215
220
|
|
|
216
221
|
### 29. `tar-add [file] [archive]` - Add a file to an existing `.tar` archive
|
|
217
222
|
|
|
223
|
+
---
|
|
224
|
+
|
|
218
225
|
```bash
|
|
219
226
|
cmd tar-add newfile.txt archive.tar
|
|
220
227
|
```
|
|
221
228
|
|
|
229
|
+
### 30. `unzip-all [source directory] [target directory]` - Extract all `.zip` files found in a specified directory into a target directory
|
|
230
|
+
|
|
231
|
+
```bash
|
|
232
|
+
cmd unzip-all /path/to/zips /path/to/extract
|
|
233
|
+
```
|
|
234
|
+
This command will find all `.zip` files in `/path/to/zips` and extract each into `/path/to/extract`.
|
|
235
|
+
|
|
236
|
+
### 31. `zip-compress [output file.zip] [directory or file ...]` - Create a `.zip` file that includes multiple specified directories or files
|
|
237
|
+
|
|
238
|
+
```bash
|
|
239
|
+
cmd zip-compress /path/to/output.zip /path/to/dir1 /path/to/dir2
|
|
240
|
+
```
|
|
241
|
+
This command will create a `.zip` file at `/path/to/output.zip` that contains everything in `/path/to/dir1` and `/path/to/dir2`.
|
|
242
|
+
|
|
222
243
|
---
|
|
223
244
|
|
|
224
245
|
## Contributing
|
|
@@ -240,5 +261,3 @@ Thank you for your interest in contributing to `linux-command`! Your contributio
|
|
|
240
261
|
## License
|
|
241
262
|
|
|
242
263
|
This project is licensed under the MIT License.
|
|
243
|
-
|
|
244
|
-
To encourage contributions and pull requests from the community, you can add a section to your `README.md` that welcomes contributions. This section typically explains how people can contribute to the project, submit issues, and make pull requests. It’s also a good idea to outline some basic guidelines for contributing (e.g., coding style, creating issues before pull requests).
|
|
@@ -31,7 +31,7 @@ import glob
|
|
|
31
31
|
|
|
32
32
|
|
|
33
33
|
# Define the version
|
|
34
|
-
VERSION = "0.0
|
|
34
|
+
VERSION = "0.2.0"
|
|
35
35
|
PROJECT_URL = "https://github.com/MouxiaoHuang/linux-command"
|
|
36
36
|
|
|
37
37
|
|
|
@@ -201,30 +201,43 @@ def main():
|
|
|
201
201
|
|
|
202
202
|
# Tar compression and decompression
|
|
203
203
|
elif args.command == 'tar-compress':
|
|
204
|
-
if len(args.extra)
|
|
204
|
+
if len(args.extra) >= 2:
|
|
205
205
|
source = args.extra[0]
|
|
206
206
|
output = args.extra[1]
|
|
207
|
+
exclude = args.extra[2:] # Additional arguments as exclude patterns
|
|
208
|
+
exclude_params = ' '.join(f'--exclude={x}' for x in exclude)
|
|
207
209
|
if output.endswith('.tar.gz'):
|
|
208
|
-
os.system(f'tar -czvf {output} {source}')
|
|
210
|
+
os.system(f'tar -czvf {output} {exclude_params} {source}')
|
|
209
211
|
elif output.endswith('.tar'):
|
|
210
|
-
os.system(f'tar -cvf {output} {source}')
|
|
212
|
+
os.system(f'tar -cvf {output} {exclude_params} {source}')
|
|
211
213
|
else:
|
|
212
214
|
print('Unsupported output format. Please provide .tar or .tar.gz as the output file extension.')
|
|
213
215
|
else:
|
|
214
216
|
print('Please provide a source and output file for tar compression')
|
|
215
217
|
|
|
216
218
|
elif args.command == 'tar-extract':
|
|
217
|
-
if len(args.extra)
|
|
218
|
-
|
|
219
|
+
if len(args.extra) >= 2:
|
|
220
|
+
source = args.extra[0]
|
|
219
221
|
destination = args.extra[1]
|
|
220
|
-
if
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
222
|
+
file_type = args.extra[2] if len(args.extra) > 2 else "all" # Optional file type filter
|
|
223
|
+
|
|
224
|
+
if os.path.isdir(source): # Check if source is a directory
|
|
225
|
+
if file_type[-3:] == "tar":
|
|
226
|
+
tar_files = glob.glob(os.path.join(source, '*.tar'))
|
|
227
|
+
elif file_type[-2:] == "gz":
|
|
228
|
+
tar_files = glob.glob(os.path.join(source, '*.tar.gz'))
|
|
229
|
+
else: # Extract all tar and tar.gz files
|
|
230
|
+
tar_files = glob.glob(os.path.join(source, '*.tar')) + glob.glob(os.path.join(source, '*.tar.gz'))
|
|
231
|
+
|
|
232
|
+
for tar_file in tar_files:
|
|
233
|
+
os.system(f'tar -xzf {tar_file} -C {destination}')
|
|
234
|
+
elif source.endswith('.tar.gz') or source.endswith('.tar'):
|
|
235
|
+
# Extract a single tar file
|
|
236
|
+
os.system(f'tar -xzf {source} -C {destination}')
|
|
224
237
|
else:
|
|
225
|
-
print('
|
|
226
|
-
|
|
227
|
-
|
|
238
|
+
print('Please provide a valid .tar or .tar.gz file, or a directory containing such files.')
|
|
239
|
+
|
|
240
|
+
|
|
228
241
|
|
|
229
242
|
elif args.command == 'tar-list':
|
|
230
243
|
if len(args.extra) > 0:
|
|
@@ -237,6 +250,26 @@ def main():
|
|
|
237
250
|
os.system(f'tar -rvf {args.extra[1]} {args.extra[0]}')
|
|
238
251
|
else:
|
|
239
252
|
print('Please provide a file to add and the target tar file')
|
|
253
|
+
|
|
254
|
+
# Unzip
|
|
255
|
+
elif args.command == 'unzip-all':
|
|
256
|
+
if len(args.extra) == 2:
|
|
257
|
+
source_dir = args.extra[0]
|
|
258
|
+
target_dir = args.extra[1]
|
|
259
|
+
os.system(f'find {source_dir} -name "*.zip" -exec unzip {{}} -d {target_dir} \;')
|
|
260
|
+
else:
|
|
261
|
+
print('Please provide both a source and a target directory.')
|
|
262
|
+
|
|
263
|
+
# Zip compress
|
|
264
|
+
elif args.command == 'zip-all':
|
|
265
|
+
if len(args.extra) >= 2:
|
|
266
|
+
output = args.extra[0]
|
|
267
|
+
sources = args.extra[1:] # All other arguments as sources to be zipped
|
|
268
|
+
source_params = ' '.join(sources)
|
|
269
|
+
os.system(f'zip -r {output} {source_params}')
|
|
270
|
+
else:
|
|
271
|
+
print('Please provide an output file name and at least one source to compress.')
|
|
272
|
+
|
|
240
273
|
|
|
241
274
|
if __name__ == '__main__':
|
|
242
275
|
main()
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: linux-command
|
|
3
|
-
Version: 0.0
|
|
3
|
+
Version: 0.2.0
|
|
4
4
|
Summary: A command line tool to perform custom tasks.
|
|
5
5
|
Home-page: https://github.com/MouxiaoHuang/linux-command
|
|
6
6
|
Author: Mouxiao Huang
|
|
@@ -192,32 +192,37 @@ cmd grep "search_term" /path/to/file
|
|
|
192
192
|
|
|
193
193
|
---
|
|
194
194
|
|
|
195
|
-
### 26. `tar-compress [source] [output]` - Compress
|
|
196
|
-
|
|
197
|
-
- For `.tar.gz`:
|
|
195
|
+
### 26. `tar-compress [source directory] [output file] [--exclude file_or_directory ...]` - Compress directories into `.tar` or `.tar.gz` while excluding specific files or folders
|
|
198
196
|
|
|
199
197
|
```bash
|
|
200
|
-
cmd tar-compress /path/to/source
|
|
198
|
+
cmd tar-compress /path/to/source /path/to/output.tar.gz --exclude node_modules --exclude .git
|
|
201
199
|
```
|
|
200
|
+
This command will compress `/path/to/source` into `/path/to/output.tar.gz` and exclude the `node_modules` and `.git` directories.
|
|
201
|
+
|
|
202
|
+
### 27. `tar-extract [source] [destination directory]` - Extract a single file or all `.tar`/`.tar.gz` files from a specified directory
|
|
202
203
|
|
|
203
|
-
-
|
|
204
|
+
- To extract a single `.tar` or `.tar.gz` file:
|
|
204
205
|
|
|
205
206
|
```bash
|
|
206
|
-
cmd tar-
|
|
207
|
+
cmd tar-extract /path/to/archive.tar.gz /path/to/destination
|
|
207
208
|
```
|
|
208
209
|
|
|
209
|
-
|
|
210
|
+
- To extract all `.tar` and `.tar.gz` files within a directory (default: all):
|
|
211
|
+
|
|
212
|
+
```bash
|
|
213
|
+
cmd tar-extract /path/to/directory /path/to/destination all
|
|
214
|
+
```
|
|
210
215
|
|
|
211
|
-
-
|
|
216
|
+
- To extract all `.tar` files within a directory:
|
|
212
217
|
|
|
213
218
|
```bash
|
|
214
|
-
cmd tar-extract
|
|
219
|
+
cmd tar-extract /path/to/directory /destination/path tar
|
|
215
220
|
```
|
|
216
221
|
|
|
217
|
-
-
|
|
222
|
+
- To extract all `.tar.gz` files within a directory:
|
|
218
223
|
|
|
219
224
|
```bash
|
|
220
|
-
cmd tar-extract
|
|
225
|
+
cmd tar-extract /path/to/directory /destination/path gz
|
|
221
226
|
```
|
|
222
227
|
|
|
223
228
|
### 28. `tar-list [archive]` - List contents of a `.tar` or `.tar.gz` archive
|
|
@@ -228,10 +233,26 @@ cmd tar-list archive.tar.gz
|
|
|
228
233
|
|
|
229
234
|
### 29. `tar-add [file] [archive]` - Add a file to an existing `.tar` archive
|
|
230
235
|
|
|
236
|
+
---
|
|
237
|
+
|
|
231
238
|
```bash
|
|
232
239
|
cmd tar-add newfile.txt archive.tar
|
|
233
240
|
```
|
|
234
241
|
|
|
242
|
+
### 30. `unzip-all [source directory] [target directory]` - Extract all `.zip` files found in a specified directory into a target directory
|
|
243
|
+
|
|
244
|
+
```bash
|
|
245
|
+
cmd unzip-all /path/to/zips /path/to/extract
|
|
246
|
+
```
|
|
247
|
+
This command will find all `.zip` files in `/path/to/zips` and extract each into `/path/to/extract`.
|
|
248
|
+
|
|
249
|
+
### 31. `zip-compress [output file.zip] [directory or file ...]` - Create a `.zip` file that includes multiple specified directories or files
|
|
250
|
+
|
|
251
|
+
```bash
|
|
252
|
+
cmd zip-compress /path/to/output.zip /path/to/dir1 /path/to/dir2
|
|
253
|
+
```
|
|
254
|
+
This command will create a `.zip` file at `/path/to/output.zip` that contains everything in `/path/to/dir1` and `/path/to/dir2`.
|
|
255
|
+
|
|
235
256
|
---
|
|
236
257
|
|
|
237
258
|
## Contributing
|
|
@@ -253,5 +274,3 @@ Thank you for your interest in contributing to `linux-command`! Your contributio
|
|
|
253
274
|
## License
|
|
254
275
|
|
|
255
276
|
This project is licensed under the MIT License.
|
|
256
|
-
|
|
257
|
-
To encourage contributions and pull requests from the community, you can add a section to your `README.md` that welcomes contributions. This section typically explains how people can contribute to the project, submit issues, and make pull requests. It’s also a good idea to outline some basic guidelines for contributing (e.g., coding style, creating issues before pull requests).
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|