Added dump command to console

Bryan Roe committed Aug 26, 2019 at 17:02 UTC d209eaa30edf97fc5dc5e7e1b58e38d43bf927ce
2 files changed +66
agents/meshcore.js
+33
@@ -1812,6 +1812,39 @@ function createMeshCore(agent)
1812 }
1813 break;
1814 }
1815 + case 'dump':
1816 + if (args['_'].length < 1)
1817 + {
1818 + response = 'Proper usage: dump [on/off/status]'; // Display correct command usage
1819 + }
1820 + else
1821 + {
1822 + switch(args['_'][0].toLowerCase())
1823 + {
1824 + case 'on':
1825 + process.coreDumpLocation = process.platform == 'win32' ? process.execPath.replace('.exe', '.dmp') : (process.execPath + '.dmp');
1826 + response = 'enabled';
1827 + break;
1828 + case 'off':
1829 + process.coreDumpLocation = null;
1830 + response = 'disabled';
1831 + break;
1832 + case 'status':
1833 + if (process.coreDumpLocation)
1834 + {
1835 + response = 'Core Dump: [ENABLED' + (require('fs').existsSync(process.coreDumpLocation) ? (', (DMP file exists)]') : (']'));
1836 + }
1837 + else
1838 + {
1839 + response = 'Core Dump: [DISABLED]';
1840 + }
1841 + break;
1842 + default:
1843 + response = 'Proper usage: dump [on/off/status]'; // Display correct command usage
1844 + break;
1845 + }
1846 + }
1847 + break;
1848 case 'eval': { // Eval JavaScript
1849 if (args['_'].length < 1) {
1850 response = 'Proper usage: eval "JavaScript code"'; // Display correct command usage
agents/meshcore.min.js
+33
@@ -1812,6 +1812,39 @@ function createMeshCore(agent)
1812 }
1813 break;
1814 }
1815 + case 'dump':
1816 + if (args['_'].length < 1)
1817 + {
1818 + response = 'Proper usage: dump [on/off/status]'; // Display correct command usage
1819 + }
1820 + else
1821 + {
1822 + switch(args['_'][0].toLowerCase())
1823 + {
1824 + case 'on':
1825 + process.coreDumpLocation = process.platform == 'win32' ? process.execPath.replace('.exe', '.dmp') : (process.execPath + '.dmp');
1826 + response = 'enabled';
1827 + break;
1828 + case 'off':
1829 + process.coreDumpLocation = null;
1830 + response = 'disabled';
1831 + break;
1832 + case 'status':
1833 + if (process.coreDumpLocation)
1834 + {
1835 + response = 'Core Dump: [ENABLED' + (require('fs').existsSync(process.coreDumpLocation) ? (', (DMP file exists)]') : (']'));
1836 + }
1837 + else
1838 + {
1839 + response = 'Core Dump: [DISABLED]';
1840 + }
1841 + break;
1842 + default:
1843 + response = 'Proper usage: dump [on/off/status]'; // Display correct command usage
1844 + break;
1845 + }
1846 + }
1847 + break;
1848 case 'eval': { // Eval JavaScript
1849 if (args['_'].length < 1) {
1850 response = 'Proper usage: eval "JavaScript code"'; // Display correct command usage