UNPKG

3.57 kBJavaScriptView Raw
1/**
2 * Copyright 2016-2018 F5 Networks, Inc.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17'use strict';
18
19const options = require('commander');
20
21/**
22 * @module
23 */
24module.exports = {
25 /**
26 * Gets common options used by all scripts.
27 *
28 * @returns {Object} An instance of commander options on which one can add options and call parse()
29 */
30 getCommonOptions(defaultLogFile) {
31 options.reboot = true;
32 options.port = 443;
33
34 /* eslint-disable max-len */
35 return options
36 .version('4.23.0-beta.3')
37 .option(
38 '--host <ip_address>',
39 'Device management IP to which to send commands.'
40 )
41 .option(
42 '-u, --user <user>',
43 'Device admin user name. Default is to create a temporary user (this only works when running on the device).'
44 )
45 .option(
46 '-p, --password [password]',
47 'Device admin user password. Use this or --password-url. One of these is required when specifying the user.'
48 )
49 .option(
50 '--password-url [password_url]',
51 'URL (file, http(s)) to location that contains device admin user password. Use this or --password. One of these is required when specifying the user.'
52 )
53 .option(
54 '--password-encrypted',
55 'Indicates that the password is encrypted (either with encryptDataToFile or generatePassword)'
56 )
57 .option(
58 '--port <port>',
59 'device management SSL port to connect to. Default 443.'
60 )
61 .option(
62 '--no-reboot',
63 'Skip reboot even if it is recommended.'
64 )
65 .option(
66 '--background',
67 'Spawn a background process to do the work. If you are running in cloud init, you probably want this option.'
68 )
69 .option(
70 '--signal <signal>',
71 'Signal to send when done. Default ONBOARD_DONE.'
72 )
73 .option(
74 '--wait-for <signal>',
75 'Wait for the named signal before running.'
76 )
77 .option(
78 '--log-level <level>',
79 'Log level (none, error, warn, info, verbose, debug, silly). Default is info.', 'info'
80 )
81 .option(
82 '-o, --output <file>',
83 `Log to file as well as console. This is the default if background process is spawned. Default is ${defaultLogFile}`
84 )
85 .option(
86 '-e, --error-file <file>',
87 'Log exceptions to a specific file. Default is /tmp/cloudLibsError.log, or cloudLibsError.log in --output file directory'
88 )
89 .option(
90 '--no-console',
91 'Do not log to console. Default false (log to console).'
92 );
93 /* eslint-enable max-len */
94 }
95};