From 119e523bc9c22d27fac473bddf6b427b4b84f7ec Mon Sep 17 00:00:00 2001 From: xmonader Date: Thu, 26 Apr 2018 23:50:35 +0200 Subject: [PATCH] Add readme with example --- README.md | 35 +++++++++++++++++++++++++++++++++++ src/dmidecode.nim | 1 - 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index aaa471c..d2bcf80 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,37 @@ # nim-dmidecode dmidecode parser in nim + + +## Example + +``` +let sample1 = """ +# dmidecode 3.1 +Getting SMBIOS data from sysfs. +SMBIOS 2.6 present. + +Handle 0x0001, DMI type 1, 27 bytes +System Information + Manufacturer: LENOVO + Product Name: 20042 + Version: Lenovo G560 + Serial Number: 2677240001087 + UUID: CB3E6A50-A77B-E011-88E9-B870F4165734 + Wake-up Type: Power Switch + SKU Number: Calpella_CRB + Family: Intel_Mobile +""" + +import dmidecode, tables + +var obj : Table[string, dmidecode.Section] +obj = parseDMI(sample) +for secname, sec in obj: + echo secname & " with " & $len(sec.props) + for k, p in sec.props: + echo "k : " & k & " => " & p.val + if len(p.items) > 0: + for i in p.items: + echo "\t\t I: ", i + +``` \ No newline at end of file diff --git a/src/dmidecode.nim b/src/dmidecode.nim index b138935..c801220 100644 --- a/src/dmidecode.nim +++ b/src/dmidecode.nim @@ -49,7 +49,6 @@ proc parseDMI* (source: string) : Table[string, Section]= if s != nil: sects[s.title] = s continue - if state == sectionName: s.title = l state = readKeyValue