docs(help) improve User Menu Example

This commit is contained in:
coderaiser 2019-05-24 13:28:20 +03:00
parent e1de247dbb
commit 4382d8ca73

33
HELP.md
View file

@ -493,7 +493,40 @@ module.exports = {
CloudCmd.refresh();
},
'C - Create User Menu File': async ({DOM, CloudCmd}) => {
const {CurrentInfo} = DOM;
const {dirPath} = CurrentInfo;
const path = `${dirPath}.cloudcmd.menu.js`;
const {prefix} = CloudCmd;
const data = await readDefaultMenu({prefix});
await createDefaultMenu({
path,
data,
DOM,
CloudCmd,
});
},
};
async function createDefaultMenu({path, data, DOM, CloudCmd}) {
const {IO} = DOM;
await IO.write(path, data);
await CloudCmd.refresh();
DOM.setCurrentByName('.cloudcmd.menu.js');
await CloudCmd.EditFile.show();
}
async function readDefaultMenu({prefix}) {
const res = await fetch(`${prefix}/api/v1/user-menu/default`);
const data = await res.text();
return data;
}
```
You will have ability to run one of this 3 commands with help of double click, enter, or binded key (`F2`, `D` or `P` in this example). Also you can run commands in terminal, or execute any built-in function of `Cloud Commander` extended it's interface.