Prepare CLI for move into mainline
This commit is contained in:
1 parent
737910f8ae
commit
a9d7b4d32a
83 files changed
No files matched your search
@@ -0,0 +1,21 @@
|
||||
# Command Functions
|
||||
|
||||
> you can use command functions to execute some code & script
|
||||
|
||||
Type Define:
|
||||
```
|
||||
Stdio: "Inherit" | "Piped" | "Null"
|
||||
```
|
||||
|
||||
### `exec(commands: [string], stdout: Stdio, stderr: Stdio)`
|
||||
|
||||
you can use this function to run some command on the current system.
|
||||
|
||||
```lua
|
||||
local cmd = plugin.command
|
||||
|
||||
manager.test = function ()
|
||||
cmd.exec({"git", "clone", "https://github.com/DioxusLabs/cli-plugin-library"})
|
||||
end
|
||||
```
|
||||
> Warning: This function don't have exception catch.
|
||||
@@ -0,0 +1,35 @@
|
||||
# Dirs Functions
|
||||
|
||||
> you can use Dirs functions to get some directory path
|
||||
|
||||
|
||||
### plugin_dir() -> string
|
||||
|
||||
You can get current plugin **root** directory path
|
||||
|
||||
```lua
|
||||
local path = plugin.dirs.plugin_dir()
|
||||
-- example: ~/Development/DioxusCli/plugin/test-plugin/
|
||||
```
|
||||
|
||||
### bin_dir() -> string
|
||||
|
||||
You can get plugin **bin** direcotry path
|
||||
|
||||
Sometime you need install some binary file like `tailwind-cli` & `sass-cli` to help your plugin work, then you should put binary file in this directory.
|
||||
|
||||
```lua
|
||||
local path = plugin.dirs.bin_dir()
|
||||
-- example: ~/Development/DioxusCli/plugin/test-plugin/bin/
|
||||
```
|
||||
|
||||
### temp_dir() -> string
|
||||
|
||||
You can get plugin **temp** direcotry path
|
||||
|
||||
Just put some temporary file in this directory.
|
||||
|
||||
```lua
|
||||
local path = plugin.dirs.bin_dir()
|
||||
-- example: ~/Development/DioxusCli/plugin/test-plugin/temp/
|
||||
```
|
||||
@@ -0,0 +1,48 @@
|
||||
# Log Functions
|
||||
|
||||
> You can use log function to print some useful log info
|
||||
|
||||
### Trace(info: string)
|
||||
|
||||
Print trace log info
|
||||
|
||||
```lua
|
||||
local log = plugin.log
|
||||
log.trace("trace information")
|
||||
```
|
||||
|
||||
### Debug(info: string)
|
||||
|
||||
Print debug log info
|
||||
|
||||
```lua
|
||||
local log = plugin.log
|
||||
log.debug("debug information")
|
||||
```
|
||||
|
||||
### Info(info: string)
|
||||
|
||||
Print info log info
|
||||
|
||||
```lua
|
||||
local log = plugin.log
|
||||
log.info("info information")
|
||||
```
|
||||
|
||||
### Warn(info: string)
|
||||
|
||||
Print warning log info
|
||||
|
||||
```lua
|
||||
local log = plugin.log
|
||||
log.warn("warn information")
|
||||
```
|
||||
|
||||
### Error(info: string)
|
||||
|
||||
Print error log info
|
||||
|
||||
```lua
|
||||
local log = plugin.log
|
||||
log.error("error information")
|
||||
```
|
||||
@@ -0,0 +1,34 @@
|
||||
# Network Functions
|
||||
|
||||
> you can use Network functions to download & read some data from internet
|
||||
|
||||
### download_file(url: string, path: string) -> boolean
|
||||
|
||||
This function can help you download some file from url, and it will return a *boolean* value to check the download status. (true: success | false: fail)
|
||||
|
||||
You need pass a target url and a local path (where you want to save this file)
|
||||
|
||||
```lua
|
||||
-- this file will download to plugin temp directory
|
||||
local status = plugin.network.download_file(
|
||||
"http://xxx.com/xxx.zip",
|
||||
plugin.dirs.temp_dir()
|
||||
)
|
||||
if status != true then
|
||||
log.error("Download Failed")
|
||||
end
|
||||
```
|
||||
|
||||
### clone_repo(url: string, path: string) -> boolean
|
||||
|
||||
This function can help you use `git clone` command (this system must have been installed git)
|
||||
|
||||
```lua
|
||||
local status = plugin.network.clone_repo(
|
||||
"http://github.com/mrxiaozhuox/dioxus-starter",
|
||||
plugin.dirs.bin_dir()
|
||||
)
|
||||
if status != true then
|
||||
log.error("Clone Failed")
|
||||
end
|
||||
```
|
||||
@@ -0,0 +1,11 @@
|
||||
# OS Functions
|
||||
|
||||
> you can use OS functions to get some system information
|
||||
|
||||
### current_platform() -> string ("windows" | "macos" | "linux")
|
||||
|
||||
This function can help you get system & platform type:
|
||||
|
||||
```lua
|
||||
local platform = plugin.os.current_platform()
|
||||
```
|
||||
@@ -0,0 +1,35 @@
|
||||
# Path Functions
|
||||
|
||||
> you can use path functions to operate valid path string
|
||||
|
||||
### join(path: string, extra: string) -> string
|
||||
|
||||
This function can help you extend a path, you can extend any path, dirname or filename.
|
||||
|
||||
```lua
|
||||
local current_path = "~/hello/dioxus"
|
||||
local new_path = plugin.path.join(current_path, "world")
|
||||
-- new_path = "~/hello/dioxus/world"
|
||||
```
|
||||
|
||||
### parent(path: string) -> string
|
||||
|
||||
This function will return `path` parent-path string, back to the parent.
|
||||
|
||||
```lua
|
||||
local current_path = "~/hello/dioxus"
|
||||
local new_path = plugin.path.parent(current_path)
|
||||
-- new_path = "~/hello/"
|
||||
```
|
||||
|
||||
### exists(path: string) -> boolean
|
||||
|
||||
This function can check some path (dir & file) is exists.
|
||||
|
||||
### is_file(path: string) -> boolean
|
||||
|
||||
This function can check some path is a exist file.
|
||||
|
||||
### is_dir(path: string) -> boolean
|
||||
|
||||
This function can check some path is a exist dir.
|
||||
Reference in new issue
Block a user