Browse Source

Added help option and fancy ASCII - just because

rune 1 year ago
parent
commit
ba1ffb5c7a
2 changed files with 21 additions and 0 deletions
  1. 20
    0
      index.js
  2. 1
    0
      package.json

+ 20
- 0
index.js View File

@@ -1,10 +1,15 @@
1 1
 #!/usr/bin/env node
2 2
 var request = require('request');
3 3
 var fs = require('fs');
4
+var figlet = require('figlet');
4 5
 var args = process.argv;
5 6
 var includeIP6 = false;
6 7
 var IP6;
7 8
 var updated = false;
9
+if(process.argv.indexOf('-h') != -1 || process.argv.indexOf('--help') != -1 ){
10
+    showHelp();
11
+    process.exit();
12
+};
8 13
 try{
9 14
     var configFileId = process.argv.indexOf('--config');
10 15
     var config = JSON.parse(fs.readFileSync(process.argv[configFileId+1], 'utf8'));
@@ -129,6 +134,21 @@ function getDomainInfo(){
129 134
     }
130 135
     return domainInfo;
131 136
 }
137
+
138
+function showHelp(){
139
+    console.log(figlet.textSync('dynDNS', {
140
+    horizontalLayout: 'default',
141
+    verticalLayout: 'default'
142
+}));
143
+    console.log('\r\ndynDNS updates your Digital Ocean DNS record with your local (public) IPv4 and IPv6');
144
+    console.log('Usage :');
145
+    console.log ('dyndns --config \"/path/to/file/config.json\"');
146
+    console.log('\r\nOptions : \r\n         -h or --help          Show this help');
147
+    console.log('         -l or --list          Lists subdomains');
148
+    console.log('         -ip6                  Include IPv6 when updating');
149
+    console.log('\r\nExample: dyndns --config \"/home/testuser/config.json\" -ip6');
150
+};
151
+
132 152
 if(process.argv.indexOf('--list') !== -1 || process.argv.indexOf('-l') !== -1){
133 153
    var domainInfo = JSON.parse(getDomainInfo());
134 154
    console.dir(domainInfo, {depth: null, colors: true});

+ 1
- 0
package.json View File

@@ -13,6 +13,7 @@
13 13
   },
14 14
   "dependencies": {
15 15
     "deasync": "^0.1.10",
16
+    "figlet": "^1.2.0",
16 17
     "request": "^2.81.0"
17 18
   }
18 19
 }

Loading…
Cancel
Save