linux-command 0.2.0__tar.gz → 0.2.2__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.2.2/LICENSE +21 -0
- {linux-command-0.2.0 → linux-command-0.2.2}/PKG-INFO +4 -3
- {linux-command-0.2.0 → linux-command-0.2.2}/README.md +2 -2
- {linux-command-0.2.0 → linux-command-0.2.2}/linux_command/linux_command.py +100 -15
- {linux-command-0.2.0 → linux-command-0.2.2}/linux_command.egg-info/PKG-INFO +4 -3
- {linux-command-0.2.0 → linux-command-0.2.2}/linux_command.egg-info/SOURCES.txt +1 -0
- {linux-command-0.2.0 → linux-command-0.2.2}/linux_command/__init__.py +0 -0
- {linux-command-0.2.0 → linux-command-0.2.2}/linux_command.egg-info/dependency_links.txt +0 -0
- {linux-command-0.2.0 → linux-command-0.2.2}/linux_command.egg-info/entry_points.txt +0 -0
- {linux-command-0.2.0 → linux-command-0.2.2}/linux_command.egg-info/top_level.txt +0 -0
- {linux-command-0.2.0 → linux-command-0.2.2}/setup.cfg +0 -0
- {linux-command-0.2.0 → linux-command-0.2.2}/setup.py +0 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Mouxiao Huang
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: linux-command
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.2
|
|
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
|
|
@@ -10,6 +10,7 @@ Classifier: License :: OSI Approved :: MIT License
|
|
|
10
10
|
Classifier: Operating System :: OS Independent
|
|
11
11
|
Requires-Python: >=3.6
|
|
12
12
|
Description-Content-Type: text/markdown
|
|
13
|
+
License-File: LICENSE
|
|
13
14
|
|
|
14
15
|
|
|
15
16
|
# linux-command
|
|
@@ -26,7 +27,7 @@ pip install linux-command
|
|
|
26
27
|
|
|
27
28
|
## Usage
|
|
28
29
|
|
|
29
|
-
Once installed, you can access all commands using `cmd` followed by the specific command name. Below is a list of supported commands along with examples for each.
|
|
30
|
+
Once installed, you can access all commands using `cmd` followed by the specific command name. You can use `cmd -h` or `cmd --help` to see the supported commands. Below is a list of supported commands along with examples for each.
|
|
30
31
|
|
|
31
32
|
---
|
|
32
33
|
|
|
@@ -257,7 +258,7 @@ This command will create a `.zip` file at `/path/to/output.zip` that contains ev
|
|
|
257
258
|
|
|
258
259
|
## Contributing
|
|
259
260
|
|
|
260
|
-
We welcome contributions from the community! If you'd like to help improve `linux-command`,
|
|
261
|
+
We welcome contributions from the community! If you'd like to help improve `linux-command`, feel free to report issues or submit pull requests.
|
|
261
262
|
|
|
262
263
|
### Guidelines for Contributors
|
|
263
264
|
|
|
@@ -13,7 +13,7 @@ pip install linux-command
|
|
|
13
13
|
|
|
14
14
|
## Usage
|
|
15
15
|
|
|
16
|
-
Once installed, you can access all commands using `cmd` followed by the specific command name. Below is a list of supported commands along with examples for each.
|
|
16
|
+
Once installed, you can access all commands using `cmd` followed by the specific command name. You can use `cmd -h` or `cmd --help` to see the supported commands. Below is a list of supported commands along with examples for each.
|
|
17
17
|
|
|
18
18
|
---
|
|
19
19
|
|
|
@@ -244,7 +244,7 @@ This command will create a `.zip` file at `/path/to/output.zip` that contains ev
|
|
|
244
244
|
|
|
245
245
|
## Contributing
|
|
246
246
|
|
|
247
|
-
We welcome contributions from the community! If you'd like to help improve `linux-command`,
|
|
247
|
+
We welcome contributions from the community! If you'd like to help improve `linux-command`, feel free to report issues or submit pull requests.
|
|
248
248
|
|
|
249
249
|
### Guidelines for Contributors
|
|
250
250
|
|
|
@@ -31,10 +31,59 @@ import glob
|
|
|
31
31
|
|
|
32
32
|
|
|
33
33
|
# Define the version
|
|
34
|
-
VERSION = "0.2.
|
|
34
|
+
VERSION = "0.2.2"
|
|
35
35
|
PROJECT_URL = "https://github.com/MouxiaoHuang/linux-command"
|
|
36
36
|
|
|
37
37
|
|
|
38
|
+
# Command descriptions
|
|
39
|
+
commands = {
|
|
40
|
+
'ls': 'List contents.',
|
|
41
|
+
'lsf': 'Count all files or filter by a specified pattern, extension or keyword. Same as `ls-file`.',
|
|
42
|
+
'ls-file': 'Count all files or filter by a specified pattern, extension or keyword. Same as `lsf`.',
|
|
43
|
+
'lsd': 'Count all directories. Same as `ls-dir`.',
|
|
44
|
+
'ls-dir': 'Count all directories. Same as `lsd`.',
|
|
45
|
+
'ls-reverse': 'List files and directories in reverse order.',
|
|
46
|
+
'ls-time': 'List sorted by modification time, newest first.',
|
|
47
|
+
'ls-recursive-size': 'List all files and directories recursively, with sizes in human-readable format',
|
|
48
|
+
'ls-bs': 'Display the size of each file in specified block size (e.g., K, M, G).',
|
|
49
|
+
'ls-size': 'Display the size of each file in specified block size (e.g., K, M, G).',
|
|
50
|
+
'ls-block-size': 'Display the size of each file in specified block size (e.g., K, M, G).',
|
|
51
|
+
'ps': 'Basic process list.',
|
|
52
|
+
'ps-all': 'Show all processes.',
|
|
53
|
+
'ps-user': 'Show processes for a specific user',
|
|
54
|
+
'ps-aux': 'Show detailed information about all processes.',
|
|
55
|
+
'ps-sort-memory': 'Sort processes by memory usage.',
|
|
56
|
+
'ps-sort-cpu': 'Sort processes by CPU usage.',
|
|
57
|
+
'ps-grep': 'Search for a specific process by name or keyword.',
|
|
58
|
+
'kill': 'Kill a process with PID or keyword in its name.',
|
|
59
|
+
'df': 'Show disk usage.',
|
|
60
|
+
'du': 'Show disk usage of a directory. Default: current directory.',
|
|
61
|
+
'disk': 'Show disk usage of a directory. Default: current directory.',
|
|
62
|
+
'rm': 'Remove file, directory, or multiple files by patterns (e.g., *.txt)',
|
|
63
|
+
'grep': 'Search for a pattern in files or output.',
|
|
64
|
+
'tar': 'Pack into .tar or .tar.gz file.',
|
|
65
|
+
'tar-comress': 'Pack into .tar or .tar.gz file.',
|
|
66
|
+
'untar': 'Unpack .tar or .tar.gz file, or batch process in a directory.',
|
|
67
|
+
'tar-extract': 'Unpack .tar or .tar.gz file, or batch process in a directory.',
|
|
68
|
+
'tar-list': 'List all contents in a tar file.',
|
|
69
|
+
'tar-add': 'Add a file to a tar file.',
|
|
70
|
+
'zip': 'Pack a folder to a .zip file.',
|
|
71
|
+
'zip-all': 'Pack a folder to a .zip file.',
|
|
72
|
+
'unzip': 'Unpack all .zip files in a directory to another.',
|
|
73
|
+
'unzip-all': 'Unpack all .zip files in a directory to another.',
|
|
74
|
+
'convert-vid': 'Video pattern trans. Usage: convert-video [source file or pattern] [destination file or pattern]',
|
|
75
|
+
'convert-video': 'Video pattern trans. Usage: convert-video [source file or pattern] [destination file or pattern]',
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def custom_help():
|
|
80
|
+
print("Available commands:")
|
|
81
|
+
for command, description in commands.items():
|
|
82
|
+
print(f'[{command}]: {description}')
|
|
83
|
+
print(f"For more information, visit: {PROJECT_URL}")
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
|
|
38
87
|
def confirm_action(message):
|
|
39
88
|
"""Ask the user to confirm an action, accepting y/n or yes/no"""
|
|
40
89
|
confirmation = input(f"{message} (yes/no or y/n): ").strip().lower()
|
|
@@ -46,19 +95,27 @@ def main():
|
|
|
46
95
|
parser = argparse.ArgumentParser(
|
|
47
96
|
description="Linux Command Wrapper - Execute common Linux commands easily",
|
|
48
97
|
epilog=f"Project page: {PROJECT_URL}",
|
|
49
|
-
add_help=
|
|
98
|
+
add_help=False
|
|
50
99
|
)
|
|
51
100
|
|
|
52
|
-
|
|
53
|
-
parser.add_argument('-V', '--version', action='
|
|
101
|
+
parser.add_argument('-h', '--help', action='store_true', help='Show this help message and exit')
|
|
102
|
+
parser.add_argument('-V', '--version', action='store_true', help='Show program\'s version number and exit')
|
|
54
103
|
|
|
55
104
|
# Main command and subcommands
|
|
56
|
-
parser.add_argument('command',
|
|
105
|
+
parser.add_argument('command', nargs='?', help='Command to execute')
|
|
57
106
|
parser.add_argument('extra', nargs='*', help='Additional arguments for the command')
|
|
58
107
|
|
|
59
108
|
# Parse the arguments
|
|
60
109
|
args = parser.parse_args()
|
|
61
110
|
|
|
111
|
+
if args.help:
|
|
112
|
+
custom_help()
|
|
113
|
+
return
|
|
114
|
+
|
|
115
|
+
if args.version:
|
|
116
|
+
print(f'linux-command {VERSION}')
|
|
117
|
+
return
|
|
118
|
+
|
|
62
119
|
# `ls` commands
|
|
63
120
|
if args.command == 'ls':
|
|
64
121
|
if len(args.extra) == 0:
|
|
@@ -70,13 +127,18 @@ def main():
|
|
|
70
127
|
|
|
71
128
|
# Advanced `ls` commands
|
|
72
129
|
|
|
73
|
-
elif args.command == 'ls-dir':
|
|
130
|
+
elif args.command == 'ls-dir' or args.command == 'lsd':
|
|
74
131
|
# Count the number of directories
|
|
75
132
|
os.system('ls -lR | grep "^d" | wc -l')
|
|
76
133
|
|
|
77
|
-
elif args.command == 'ls-file':
|
|
78
|
-
|
|
79
|
-
|
|
134
|
+
elif args.command == 'ls-file' or args.command == 'lsf':
|
|
135
|
+
if len(args.extra) == 0:
|
|
136
|
+
# Count the number of all files
|
|
137
|
+
os.system('ls -l | grep "^-" | wc -l')
|
|
138
|
+
else:
|
|
139
|
+
# Count files of a specific type based on provided extension or pattern
|
|
140
|
+
pattern = args.extra[0] # First extra argument as file pattern
|
|
141
|
+
os.system(f'ls -l | grep "^-" | grep "{pattern}" | wc -l')
|
|
80
142
|
|
|
81
143
|
elif args.command == 'ls-reverse':
|
|
82
144
|
# List files and directories in reverse order
|
|
@@ -102,7 +164,7 @@ def main():
|
|
|
102
164
|
options = ' '.join(args.extra)
|
|
103
165
|
os.system(f'ls -lRh {options}')
|
|
104
166
|
|
|
105
|
-
elif args.command == 'ls-block-size':
|
|
167
|
+
elif args.command == 'ls-block-size' or args.command == 'ls-bs' or args.command == 'ls-size':
|
|
106
168
|
# Display the size of each file in specified block size
|
|
107
169
|
if len(args.extra) == 1:
|
|
108
170
|
block_size = args.extra[0]
|
|
@@ -158,7 +220,7 @@ def main():
|
|
|
158
220
|
elif args.command == 'df':
|
|
159
221
|
os.system('df -h')
|
|
160
222
|
|
|
161
|
-
elif args.command == 'du':
|
|
223
|
+
elif args.command == 'du' or args.command == 'disk':
|
|
162
224
|
if len(args.extra) > 0:
|
|
163
225
|
os.system(f'du -sh {args.extra[0]}')
|
|
164
226
|
else:
|
|
@@ -200,7 +262,7 @@ def main():
|
|
|
200
262
|
print('Please provide a keyword and file path for grep command')
|
|
201
263
|
|
|
202
264
|
# Tar compression and decompression
|
|
203
|
-
elif args.command == 'tar-compress':
|
|
265
|
+
elif args.command == 'tar-compress' or args.command == 'tar':
|
|
204
266
|
if len(args.extra) >= 2:
|
|
205
267
|
source = args.extra[0]
|
|
206
268
|
output = args.extra[1]
|
|
@@ -215,7 +277,7 @@ def main():
|
|
|
215
277
|
else:
|
|
216
278
|
print('Please provide a source and output file for tar compression')
|
|
217
279
|
|
|
218
|
-
elif args.command == 'tar-extract':
|
|
280
|
+
elif args.command == 'tar-extract' or args.command == 'untar':
|
|
219
281
|
if len(args.extra) >= 2:
|
|
220
282
|
source = args.extra[0]
|
|
221
283
|
destination = args.extra[1]
|
|
@@ -252,7 +314,7 @@ def main():
|
|
|
252
314
|
print('Please provide a file to add and the target tar file')
|
|
253
315
|
|
|
254
316
|
# Unzip
|
|
255
|
-
elif args.command == 'unzip-all':
|
|
317
|
+
elif args.command == 'unzip-all' or args.command == 'unzip':
|
|
256
318
|
if len(args.extra) == 2:
|
|
257
319
|
source_dir = args.extra[0]
|
|
258
320
|
target_dir = args.extra[1]
|
|
@@ -261,7 +323,7 @@ def main():
|
|
|
261
323
|
print('Please provide both a source and a target directory.')
|
|
262
324
|
|
|
263
325
|
# Zip compress
|
|
264
|
-
elif args.command == 'zip-all':
|
|
326
|
+
elif args.command == 'zip-all' or args.command == 'zip':
|
|
265
327
|
if len(args.extra) >= 2:
|
|
266
328
|
output = args.extra[0]
|
|
267
329
|
sources = args.extra[1:] # All other arguments as sources to be zipped
|
|
@@ -270,6 +332,29 @@ def main():
|
|
|
270
332
|
else:
|
|
271
333
|
print('Please provide an output file name and at least one source to compress.')
|
|
272
334
|
|
|
335
|
+
# ffmpeg
|
|
336
|
+
elif args.command == 'convert-video' or args.command == 'convert-vid':
|
|
337
|
+
if len(args.extra) == 2:
|
|
338
|
+
source = args.extra[0]
|
|
339
|
+
destination = args.extra[1]
|
|
340
|
+
|
|
341
|
+
if '*' in source:
|
|
342
|
+
# Handle wildcard batch conversion
|
|
343
|
+
source_files = glob.glob(source)
|
|
344
|
+
destination_dir = os.path.dirname(destination)
|
|
345
|
+
file_extension = destination.split('.')[-1]
|
|
346
|
+
|
|
347
|
+
for src_file in source_files:
|
|
348
|
+
basename = os.path.splitext(os.path.basename(src_file))[0]
|
|
349
|
+
dest_file = os.path.join(destination_dir, f'{basename}.{file_extension}')
|
|
350
|
+
os.system(f'ffmpeg -i "{src_file}" -c copy "{dest_file}" -y')
|
|
351
|
+
else:
|
|
352
|
+
# Handle single file conversion
|
|
353
|
+
os.system(f'ffmpeg -i "{source}" -c copy "{destination}" -y')
|
|
354
|
+
else:
|
|
355
|
+
print('Usage: convert-video [source file or pattern] [destination file or pattern]')
|
|
356
|
+
|
|
357
|
+
|
|
273
358
|
|
|
274
359
|
if __name__ == '__main__':
|
|
275
360
|
main()
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: linux-command
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.2
|
|
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
|
|
@@ -10,6 +10,7 @@ Classifier: License :: OSI Approved :: MIT License
|
|
|
10
10
|
Classifier: Operating System :: OS Independent
|
|
11
11
|
Requires-Python: >=3.6
|
|
12
12
|
Description-Content-Type: text/markdown
|
|
13
|
+
License-File: LICENSE
|
|
13
14
|
|
|
14
15
|
|
|
15
16
|
# linux-command
|
|
@@ -26,7 +27,7 @@ pip install linux-command
|
|
|
26
27
|
|
|
27
28
|
## Usage
|
|
28
29
|
|
|
29
|
-
Once installed, you can access all commands using `cmd` followed by the specific command name. Below is a list of supported commands along with examples for each.
|
|
30
|
+
Once installed, you can access all commands using `cmd` followed by the specific command name. You can use `cmd -h` or `cmd --help` to see the supported commands. Below is a list of supported commands along with examples for each.
|
|
30
31
|
|
|
31
32
|
---
|
|
32
33
|
|
|
@@ -257,7 +258,7 @@ This command will create a `.zip` file at `/path/to/output.zip` that contains ev
|
|
|
257
258
|
|
|
258
259
|
## Contributing
|
|
259
260
|
|
|
260
|
-
We welcome contributions from the community! If you'd like to help improve `linux-command`,
|
|
261
|
+
We welcome contributions from the community! If you'd like to help improve `linux-command`, feel free to report issues or submit pull requests.
|
|
261
262
|
|
|
262
263
|
### Guidelines for Contributors
|
|
263
264
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|