Skip to content

Commit 08ba6a6

Browse files
committed
hostname v0.0.1
1 parent 2af88ea commit 08ba6a6

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

darkbox/commands/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
from .cp import cp
44
from .curl import curl
55
from .exip import exip
6+
from .head import head
7+
from .hostname import hostname
68
from .ls import ls
79
from .md5sum import md5sum
810
from .mv import mv

darkbox/commands/hostname.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
""" darkbox hostname command """
2+
3+
from .template import Command
4+
5+
import socket
6+
import argparse
7+
8+
9+
class hostname(Command):
10+
def __init__(self):
11+
self.version = '0.0.1'
12+
13+
def get_parser(self):
14+
parser = super().get_parser(description='darkbox hostname')
15+
parser.add_argument('-s', '--simple', action='store_true',
16+
help='trim off any domain information')
17+
return parser
18+
19+
def run(self):
20+
args = self.get_args()
21+
simple = args['simple']
22+
if simple:
23+
print(socket.gethostname().split('.')[0])
24+
else:
25+
print(socket.gethostname())

0 commit comments

Comments
 (0)