Aim: Offer docker-desktop feature of showing status of wsl (stopped/running). In Docker Desktop this can be seen in the left bottom corner.
Consequence: Parse output of wsl --list --verbose
Current implementation in main.ts of electron app:
ipcMain.on('cmd', async (event, arg)=>{
const execute = (command, callback)=>{
exec(command, (error, stdout, stderr) => {
callback(stdout);
});
};
// call the function
execute('wsl --list --verbose', (output) => {
event.sender.send('cmd-callback',output)
});
})
Problem:
Current attempt: console.log(args.split(/[
|
|
]/).filter(String))
Current result:
[
" u0000 u0000Nu0000Au0000Mu0000Eu0000 u0000 u0000 u0000 u0000 u0000 u0000 u0000 u0000 u0000 u0000 u0000 u0000 u0000 u0000 u0000 u0000 u0000 u0000 u0000Su0000Tu0000Au0000Tu0000Eu0000 u0000 u0000 u0000 u0000 u0000 u0000 u0000 u0000 u0000 u0000 u0000Vu0000Eu0000Ru0000Su0000Iu0000Ou0000Nu0000",
"u0000",
"u0000*u0000 u0000Uu0000bu0000uu0000nu0000tu0000uu0000 u0000 u0000 u0000 u0000 u0000 u0000 u0000 u0000 u0000 u0000 u0000 u0000 u0000 u0000 u0000 u0000 u0000Su0000tu0000ou0000pu0000pu0000eu0000du0000 u0000 u0000 u0000 u0000 u0000 u0000 u0000 u0000 u00002u0000",
"u0000",
"u0000 u0000 u0000du0000ou0000cu0000ku0000eu0000ru0000-u0000du0000eu0000su0000ku0000tu0000ou0000pu0000 u0000 u0000 u0000 u0000 u0000 u0000 u0000 u0000 u0000Su0000tu0000ou0000pu0000pu0000eu0000du0000 u0000 u0000 u0000 u0000 u0000 u0000 u0000 u0000 u00002u0000",
"u0000",
"u0000 u0000 u0000du0000ou0000cu0000ku0000eu0000ru0000-u0000du0000eu0000su0000ku0000tu0000ou0000pu0000-u0000du0000au0000tu0000au0000 u0000 u0000 u0000 u0000Su0000tu0000ou0000pu0000pu0000eu0000du0000 u0000 u0000 u0000 u0000 u0000 u0000 u0000 u0000 u00002u0000",
"u0000",
"u0000"
]
Required output as a JavaScript Array [string[]]:
[
['Ubuntu', 'Stopped', '2'],
['docker-desktop', 'Stopped', '2'],
['docker-desktop-data', 'Stopped', '2'],
]