marktext/src/main/cli/index.js
bolshoytoster 2ed5a85012
Removed the space in 'Mark Text' (#2763) (#2782)
* Removed the space in 'Mark Text' (#2763)

Literally just replaced all occurances of 'Mark Text' with 'MarkText' using sed.

This is directly related to #2763.

* Revert changes to .github directory

Reverted changelog etc.

* Added `cs` alias for `csharp` in code blocks (Fixes #2760)

* Added error handler in the renderer process (should fix #2758)

The `src/muya/lib/contentState/clickCtrl.js` file will now return if
`document.querySelector` fails to find an element.
2021-12-25 21:05:58 +08:00

67 lines
2.2 KiB
JavaScript

import path from 'path'
import { app } from 'electron'
import os from 'os'
import { isDirectory } from 'common/filesystem'
import parseArgs from './parser'
import { dumpKeyboardInformation } from '../keyboard'
import { getPath } from '../utils'
const write = s => process.stdout.write(s)
const writeLine = s => write(s + '\n')
const cli = () => {
let argv = process.argv.slice(1)
if (process.env.NODE_ENV === 'development') {
// Don't pass electron development arguments to MarkText and change user data path.
argv = ['--user-data-dir', path.join(getPath('appData'), 'marktext-dev')]
}
const args = parseArgs(argv, true)
if (args['--help']) {
write(`Usage: marktext [commands] [path ...]
Available commands:
--debug Enable debug mode
--safe Disable plugins and other user configuration
--dump-keyboard-layout Dump keyboard information
-n, --new-window Open a new window on second-instance
--user-data-dir Change the user data directory
--disable-gpu Disable GPU hardware acceleration
-v, --verbose Be verbose
--version Print version information
-h, --help Print this help message
`)
process.exit(0)
}
if (args['--version']) {
writeLine(`MarkText: ${global.MARKTEXT_VERSION_STRING}`)
writeLine(`Node.js: ${process.versions.node}`)
writeLine(`Electron: ${process.versions.electron}`)
writeLine(`Chromium: ${process.versions.chrome}`)
writeLine(`OS: ${os.type()} ${os.arch()} ${os.release()}`)
process.exit(0)
}
if (args['--dump-keyboard-layout']) {
writeLine(dumpKeyboardInformation())
process.exit(0)
}
// Check for portable mode and ensure the user data path is absolute. We assume
// that the path is writable if not this lead to an application crash.
if (!args['--user-data-dir']) {
const portablePath = path.join(app.getAppPath(), '..', '..', 'marktext-user-data')
if (isDirectory(portablePath)) {
args['--user-data-dir'] = portablePath
}
} else {
args['--user-data-dir'] = path.resolve(args['--user-data-dir'])
}
return args
}
export default cli