Add profiles module docs and samples
This commit is contained in:
10
README.md
10
README.md
@@ -599,6 +599,16 @@ _Avaialble from: 4.1.0_
|
|||||||
|
|
||||||
All data are returned in `on_cloud_result(meta, content)`. The first argument is the metadata, either a metadata table (in the case of `list_dir()`) or an error message string. The second argument is the contents of the file (in the case of `get_file()`).
|
All data are returned in `on_cloud_result(meta, content)`. The first argument is the metadata, either a metadata table (in the case of `list_dir()`) or an error message string. The second argument is the contents of the file (in the case of `get_file()`).
|
||||||
|
|
||||||
|
## Profiles
|
||||||
|
|
||||||
|
_Avaialble from: 5.3.6._
|
||||||
|
|
||||||
|
* `profiles:list()` - returns a list of saved profiles;
|
||||||
|
* `profiles:dump(name)` - saves a new profile with the specified name;
|
||||||
|
* `profiles:restore(name)` - restores the saved profile;
|
||||||
|
* `profiles:dump_json()` - creates a new profile but instead of saving it, returns it as a JSON string;
|
||||||
|
* `profiles:restore_json(json)` - restores a profile previously saved using `dump_json()`.
|
||||||
|
|
||||||
## AI
|
## AI
|
||||||
|
|
||||||
_Avaialble from: 5.3.5._
|
_Avaialble from: 5.3.5._
|
||||||
|
|||||||
13
samples/profiles_sample1.lua
Normal file
13
samples/profiles_sample1.lua
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
-- This sample lists current system profiles and allows to restore any of it
|
||||||
|
|
||||||
|
profs = {}
|
||||||
|
|
||||||
|
function on_resume()
|
||||||
|
profs = profiles:list()
|
||||||
|
ui:show_lines(profiles:list())
|
||||||
|
end
|
||||||
|
|
||||||
|
function on_click(idx)
|
||||||
|
ui:show_toast("Restoring...")
|
||||||
|
profiles:restore(profs[idx])
|
||||||
|
end
|
||||||
20
samples/profiles_sample2.lua
Normal file
20
samples/profiles_sample2.lua
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
-- This script shows how to dump/restore profile without saving it to the system
|
||||||
|
|
||||||
|
curr_profile = ""
|
||||||
|
|
||||||
|
function on_resume()
|
||||||
|
ui:show_lines{
|
||||||
|
"Dump profile",
|
||||||
|
"Restore profile"
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
function on_click(idx)
|
||||||
|
if idx == 1 then
|
||||||
|
curr_profile = profiles:dump_json()
|
||||||
|
ui:show_toast("Saved")
|
||||||
|
else
|
||||||
|
ui:show_toast("Restoring...")
|
||||||
|
profiles:restore_json(curr_profile)
|
||||||
|
end
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user