linux-command 0.2.1__tar.gz → 0.2.3__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.1
2
2
  Name: linux-command
3
- Version: 0.2.1
3
+ Version: 0.2.3
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
@@ -31,7 +31,7 @@ import glob
31
31
 
32
32
 
33
33
  # Define the version
34
- VERSION = "0.2.1"
34
+ VERSION = "0.2.3"
35
35
  PROJECT_URL = "https://github.com/MouxiaoHuang/linux-command"
36
36
 
37
37
 
@@ -44,9 +44,11 @@ commands = {
44
44
  'ls-dir': 'Count all directories. Same as `lsd`.',
45
45
  'ls-reverse': 'List files and directories in reverse order.',
46
46
  'ls-time': 'List sorted by modification time, newest first.',
47
+ 'ls-human': 'List in human-readable format (for file sizes)',
48
+ 'ls-long': 'Long format listing',
49
+ 'ls-size': 'Sort files by size',
47
50
  'ls-recursive-size': 'List all files and directories recursively, with sizes in human-readable format',
48
51
  '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
52
  'ls-block-size': 'Display the size of each file in specified block size (e.g., K, M, G).',
51
53
  'ps': 'Basic process list.',
52
54
  'ps-all': 'Show all processes.',
@@ -76,6 +78,14 @@ commands = {
76
78
  }
77
79
 
78
80
 
81
+ def custom_help():
82
+ print("Available commands:")
83
+ for command, description in commands.items():
84
+ print(f'[{command}]: {description}')
85
+ print(f"For more information, visit: {PROJECT_URL}")
86
+
87
+
88
+
79
89
  def confirm_action(message):
80
90
  """Ask the user to confirm an action, accepting y/n or yes/no"""
81
91
  confirmation = input(f"{message} (yes/no or y/n): ").strip().lower()
@@ -91,29 +101,21 @@ def main():
91
101
  )
92
102
 
93
103
  parser.add_argument('-h', '--help', action='store_true', help='Show this help message and exit')
94
- parser.add_argument('-V', '-v', '--version', action='version', version=f'linux-command {VERSION}', help='Show program\'s version number and exit')
104
+ parser.add_argument('-V', '--version', action='store_true', help='Show program\'s version number and exit')
95
105
 
96
106
  # Main command and subcommands
97
- parser.add_argument('command', type=str, help='Command to execute')
107
+ parser.add_argument('command', nargs='?', help='Command to execute')
98
108
  parser.add_argument('extra', nargs='*', help='Additional arguments for the command')
99
109
 
100
110
  # Parse the arguments
101
111
  args = parser.parse_args()
102
112
 
103
113
  if args.help:
104
- if args.command:
105
- # Show help for a specific command
106
- print(f'{args.command}: {commands.get(args.command, "No help available for this command.")}')
107
- else:
108
- # Show help for all commands
109
- print("Available commands:")
110
- for command, description in commands.items():
111
- print(f' {command}: {description}')
112
- print("\nUse 'cmd -h [command]' to see help for a specific command.")
114
+ custom_help()
113
115
  return
114
116
 
115
- if not args.command:
116
- parser.print_help()
117
+ if args.version:
118
+ print(f'linux-command {VERSION}')
117
119
  return
118
120
 
119
121
  # `ls` commands
@@ -156,6 +158,22 @@ def main():
156
158
  options = ' '.join(args.extra)
157
159
  os.system(f'ls -lt {options}')
158
160
 
161
+ elif args.command == 'ls-long':
162
+ # Long format listing
163
+ if len(args.extra) == 0:
164
+ os.system('ls -l')
165
+ else:
166
+ options = ' '.join(args.extra)
167
+ os.system(f'ls -l {options}')
168
+
169
+ elif args.command == 'ls-human':
170
+ # List in human-readable format (for file sizes)
171
+ if len(args.extra) == 0:
172
+ os.system('ls -lh')
173
+ else:
174
+ options = ' '.join(args.extra)
175
+ os.system(f'ls -lh {options}')
176
+
159
177
  elif args.command == 'ls-recursive-size':
160
178
  # List all files and directories recursively, with sizes in human-readable format
161
179
  if len(args.extra) == 0:
@@ -164,7 +182,15 @@ def main():
164
182
  options = ' '.join(args.extra)
165
183
  os.system(f'ls -lRh {options}')
166
184
 
167
- elif args.command == 'ls-block-size' or args.command == 'ls-bs' or args.command == 'ls-size':
185
+ elif args.command == 'ls-size':
186
+ # Sort files by size
187
+ if len(args.extra) == 0:
188
+ os.system('ls -lS')
189
+ else:
190
+ options = ' '.join(args.extra)
191
+ os.system(f'ls -lS {options}')
192
+
193
+ elif args.command == 'ls-block-size' or args.command == 'ls-bs':
168
194
  # Display the size of each file in specified block size
169
195
  if len(args.extra) == 1:
170
196
  block_size = args.extra[0]
@@ -292,10 +318,15 @@ def main():
292
318
  tar_files = glob.glob(os.path.join(source, '*.tar')) + glob.glob(os.path.join(source, '*.tar.gz'))
293
319
 
294
320
  for tar_file in tar_files:
295
- os.system(f'tar -xzf {tar_file} -C {destination}')
296
- elif source.endswith('.tar.gz') or source.endswith('.tar'):
297
- # Extract a single tar file
298
- os.system(f'tar -xzf {source} -C {destination}')
321
+ if tar_file.endswith('.tar'):
322
+ os.system(f'tar -xvf {tar_file} -C {destination}')
323
+ elif tar_file.endswith('.tar.gz'):
324
+ os.system(f'tar -xzvf {tar_file} -C {destination}')
325
+ # Extract a single tar file
326
+ elif source.endswith('.tar.gz'):
327
+ os.system(f'tar -xzvf {source} -C {destination}')
328
+ elif source.endswith('.tar'):
329
+ os.system(f'tar -xvf {source} -C {destination}')
299
330
  else:
300
331
  print('Please provide a valid .tar or .tar.gz file, or a directory containing such files.')
301
332
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: linux-command
3
- Version: 0.2.1
3
+ Version: 0.2.3
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
File without changes
File without changes
File without changes
File without changes