diff --git a/README.md b/README.md index c864e7c..097d021 100644 --- a/README.md +++ b/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()`). +## 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._ diff --git a/samples/profiles_sample1.lua b/samples/profiles_sample1.lua new file mode 100644 index 0000000..955db03 --- /dev/null +++ b/samples/profiles_sample1.lua @@ -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 diff --git a/samples/profiles_sample2.lua b/samples/profiles_sample2.lua new file mode 100644 index 0000000..18634ad --- /dev/null +++ b/samples/profiles_sample2.lua @@ -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