[How To] [Task] Get (Native) Available Shell Commands (And Their Help).
Update: Last Modified: 2022-05-13 15:08:07 {
- Fix for a commands list glitch.
}
โ
A simple Task to retrieve available (toybox) Shell commands and their help.
Using the following Task, We will query toybox for commands... Than We will be able to:
- Save selected cmd(s) and help(s) to file or clipboard.
- Save all cmds and relative help to file.
File(s) will be saved in Tasker folder.
Task: Get Shell Commands Help
A1: Variable Set [
Name: %destination_path
To: Tasker
Max Rounding Digits: 3 ]
A2: Run Shell [
Command: toybox --version
Timeout (Seconds): 0
Store Output In: %toybox_version
Use Global Namespace: On
Continue Task After Error:On ]
A3: If [ %err Set ]
A4: Flash [
Text: Something went wrong!
"toybox" seems unavailable!
Long: On
Continue Task Immediately: On
Dismiss On Click: On ]
A5: Stop [ ]
A6: End If
A7: Run Shell [
Command: toybox
Timeout (Seconds): 0
Store Output In: %cmds
Continue Task After Error:On ]
A8: If [ %err Set ]
A9: Flash [
Text: Something went wrong!
Query "toybox" for commands failed!
Long: On
Continue Task Immediately: On
Dismiss On Click: On ]
A10: Stop [ ]
A11: End If
A12: Array Set [
Variable Array: %cmds
Values: %cmds ]
A13: List Dialog [
Mode: Multiple Choices
Title: Shell Commands
Items: %cmds
Button 1: Selected To File
Button 2: Selected To Clipboard
Button 3: All To File
Close After (Seconds): 86400
First Visible Index: 0
Text: [ %toybox_version ]
Continue Task After Error:On ]
A14: If [ %err Set | %ld_selected(#) = 0 &+ %ld_button neq All To File ]
A15: Flash [
Text: Cancelled. Bye!
Continue Task Immediately: On
Dismiss On Click: On ]
A16: Stop [ ]
A17: End If
A18: Array Set [
Variable Array: %ld_selected
Values: %cmds(+ยฅ)
Splitter: ยฅ ]
If [ %ld_button eq All To File ]
A19: Flash [
Text: Elaborating, please wait...
Continue Task Immediately: On
Dismiss On Click: On ]
A20: Array Process [
Variable Array: %ld_selected
Type: Sort Alpha Caseless, Reverse ]
A21: For [
Variable: %cmd
Items: %ld_selected() ]
A22: Run Shell [
Command: %cmd --help
Timeout (Seconds): 10
Store Output In: %help
Continue Task After Error:On ]
A23: Variable Set [
Name: %help
To: Help not available!
Shell error: %err
Possible reasons:
Unsupported operation or Unknown command
Online help (for latest toybox version):
https://landley.net/toybox/help.html#%cmd
Max Rounding Digits: 3 ]
If [ %err Set & %help ~R \%help ]
A24: Variable Set [
Name: %help
To: Help not available!
Shell error: No error.
Possible reasons:
Unsupported operation or Unknown command
Online help (for latest toybox version):
https://landley.net/toybox/help.html#%cmd
Max Rounding Digits: 3 ]
If [ %help ~R \%help ]
A25: Array Push [
Variable Array: %commands_help
Position: 1
Value: [ %cmd ]
%help ]
A26: End For
A27: If [ %ld_button ~ *Clipboard ]
A28: Set Clipboard [
Text: %commands_help(+
-------------------------------------------------------------
) ]
A29: Flash [
Text: Command(s) copied to clipboard.
Continue Task Immediately: On
Dismiss On Click: On
Use HTML: On ]
A30: Else
A31: If [ %ld_button ~ All* ]
A32: Variable Set [
Name: %file_name
To: ShellCommandsHelp.txt
Max Rounding Digits: 3 ]
A33: Else
A34: Variable Set [
Name: %file_name
To: ShellCommandsHelp_Selected.txt
Max Rounding Digits: 3 ]
A35: End If
A36: Write File [
File: %destination_path/%file_name
Text: %commands_help(+
-------------------------------------------------------------
)
Continue Task After Error:On ]
A37: If [ %err Set ]
A38: Flash [
Text: Something went wrong! Error saving commands to file!
Long: On
Continue Task Immediately: On
Dismiss On Click: On
Use HTML: On ]
A39: Else
A40: Flash [
Text: Command(s) saved to file:
%destination_path/%file_name
Long: On
Continue Task Immediately: On
Dismiss On Click: On
Use HTML: On ]
A41: End If
A42: End If
Download:
Taskernet - Get Shell Commands Help
Taskernet - Get Shell Commands Help - Android Lollipop
I hope You will find this post useful.
โ
^^u/OwlIsBack
Posted Feb 10, 2022, 3:13 PM UTC ยท edited
Post of the Year. It's just refreshing to see a job well thought out and well done.
Owl, I think Joฤo should bundle this with Tasker
Peeps, especially if you're new, try the date command help.
Thanks, Ella :) I appreciate.