MCPcopy
hub / github.com/marktext/marktext / cli

Function cli

packages/desktop/src/main/cli/index.ts:11–58  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

9const writeLine = (s: string): boolean => write(s + '\n')
10
11const cli = (): ParsedArgs => {
12 let argv = process.argv.slice(1)
13 if (process.env.NODE_ENV === 'development') {
14 // Don't pass electron development arguments to MarkText and change user data path.
15 argv = ['--user-data-dir', path.join(getPath('appData'), 'marktext-dev')]
16 }
17
18 const args = parseArgs(argv, true)
19 if (args['--help']) {
20 write(`Usage: marktext [commands] [path ...]
21
22 Available commands:
23
24 --debug Enable debug mode
25 --safe Disable plugins and other user configuration
26 -n, --new-window Open a new window on second-instance
27 --user-data-dir Change the user data directory
28 --disable-gpu Disable GPU hardware acceleration
29 --disable-spellcheck Disable built-in spellchecker
30 -v, --verbose Be verbose
31 --version Print version information
32 -h, --help Print this help message
33`)
34 process.exit(0)
35 }
36
37 if (args['--version']) {
38 writeLine(`MarkText: ${MARKTEXT_VERSION_STRING}`)
39 writeLine(`Node.js: ${process.versions.node}`)
40 writeLine(`Electron: ${process.versions.electron}`)
41 writeLine(`Chromium: ${process.versions.chrome}`)
42 writeLine(`OS: ${os.type()} ${os.arch()} ${os.release()}`)
43 process.exit(0)
44 }
45
46 // Check for portable mode and ensure the user data path is absolute. We assume
47 // that the path is writable if not this lead to an application crash.
48 if (!args['--user-data-dir']) {
49 const portablePath = path.join(app.getAppPath(), '..', '..', 'marktext-user-data')
50 if (isDirectory(portablePath)) {
51 args['--user-data-dir'] = portablePath
52 }
53 } else {
54 args['--user-data-dir'] = path.resolve(args['--user-data-dir'])
55 }
56
57 return args
58}
59
60export default cli

Callers 1

index.tsFile · 0.85

Calls 8

getPathFunction · 0.90
isDirectoryFunction · 0.90
parseArgsFunction · 0.85
writeFunction · 0.85
writeLineFunction · 0.85
joinMethod · 0.80
typeMethod · 0.80
resolveMethod · 0.80

Tested by

no test coverage detected