diff options
author | Daniil Baturin <daniil@baturin.org> | 2015-03-11 01:02:52 +0600 |
---|---|---|
committer | Daniil Baturin <daniil@baturin.org> | 2015-03-11 01:02:52 +0600 |
commit | ba78d80d8386307071225d5940bbc403e6271dfc (patch) | |
tree | cd29972e17d7a9c59fc03b6d3270799b9064e538 | |
parent | 7c0ec0eecf3395a59b1392a5bac5fc9585877104 (diff) | |
download | hvinfo-ba78d80d8386307071225d5940bbc403e6271dfc.tar.gz hvinfo-ba78d80d8386307071225d5940bbc403e6271dfc.zip |
Add option handling.
-rw-r--r-- | src/hvinfo.adb | 32 | ||||
-rw-r--r-- | src/hvinfo_util.adb | 21 | ||||
-rw-r--r-- | src/hvinfo_util.ads | 11 |
3 files changed, 64 insertions, 0 deletions
diff --git a/src/hvinfo.adb b/src/hvinfo.adb index bb682c0..06fe9f1 100644 --- a/src/hvinfo.adb +++ b/src/hvinfo.adb @@ -1,14 +1,46 @@ with Ada.Strings.Unbounded; +with Ada.Text_IO; with Ada.Text_IO.Unbounded_IO; with Ada.Command_Line; +with GNAT.Command_Line; +with GNAT.Strings; with Hypervisor_Check; use Hypervisor_Check; +with HVInfo_Util; use HVInfo_Util; procedure HVInfo is package US renames Ada.Strings.Unbounded; package CL renames Ada.Command_Line; + package IO renames Ada.Text_IO; + package GCL renames GNAT.Command_Line; + CPUID_HV_Name, SMBIOS_HV_Name, Hypervisor_Name : US.Unbounded_String; begin + -- Handle command line options + declare + -- No declarations + begin + loop + case GCL.Getopt ("-help -version") is + when '-' => + if GCL.Full_Switch = "-version" then + Print_Version; + return; + elsif GCL.Full_Switch = "-help" then + Print_Help; + return; + end if; + when others => + exit; + end case; + end loop; + exception + when GCL.Invalid_Switch => + IO.Put_Line ("Invalid option"); + Print_Help; + return; + end; + CPUID_HV_Name := US.To_Unbounded_String (""); SMBIOS_HV_Name := US.To_Unbounded_String (""); diff --git a/src/hvinfo_util.adb b/src/hvinfo_util.adb new file mode 100644 index 0000000..daad56d --- /dev/null +++ b/src/hvinfo_util.adb @@ -0,0 +1,21 @@ +package body HVInfo_Util is + + procedure Print_Help is + begin + IO.Put_Line ("hvinfo is a hypervisor detection tool"); + IO.Put_Line ("Usage: hvinfo [--help | --version]"); + IO.Put_Line (""); + IO.Put_Line (" --help Print this message and exit"); + IO.Put_Line (" --version Print version and exit"); + end Print_Help; + + procedure Print_Version is + begin + IO.Put_Line ("hvinfo 0.1"); + IO.Put_Line ("Copyright 2015 Daniil Baturin <daniil@baturin.org>"); + IO.Put_Line (""); + IO.Put_Line ("This program is free software, distributed under the terms"); + IO.Put_Line ("of the GNU General Public License version 2 or later."); + end Print_Version; + +end HVInfo_Util; diff --git a/src/hvinfo_util.ads b/src/hvinfo_util.ads new file mode 100644 index 0000000..d45667e --- /dev/null +++ b/src/hvinfo_util.ads @@ -0,0 +1,11 @@ +with Ada.Command_line; +with Ada.Text_IO; + +package HVInfo_Util is + + package IO renames Ada.Text_IO; + + procedure Print_Version; + procedure Print_Help; + +end HVINfo_Util; |