Add profiles module docs and samples

This commit is contained in:
Evgeny
2024-08-07 20:44:11 +04:00
parent b5840ee5bb
commit d063132df2
3 changed files with 43 additions and 0 deletions

View File

@@ -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()`).
## 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
_Avaialble from: 5.3.5._

View 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

View 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