public static void Main(string[] args)
        {
            var config = new Configuration()
            {
                AddDecodedByStatement = true
            };

            var optionSet = new OptionSet()
            {
                { "s|statement=", "Add an interpretive statement (may use more than once)",
                  arg => config.AddStatement(arg) },
                { "no-patient-info", "Remove patient specific information",
                  _ => config.RemovePatientInformation = true },
                { "no-device-info", "Remove device specific information",
                  _ => config.RemoveDeviceInformation = true },
                { "no-watermark", "Do not add 'Decoded by...' statement",
                  _ => config.AddDecodedByStatement = false },
                { "?|h|help", "Show this message", _ => config.ShowHelp = true },
            };

            var extra = optionSet.Parse(args);

            if (!extra.Any() || config.ShowHelp)
            {
                Console.Error.WriteLine("XliDecompressor.exe [OPTIONS] <input files (XML, TGZ, GZ, TAR)>");
                optionSet.WriteOptionDescriptions(Console.Error);
                Environment.Exit(-1);
            }
            else
            {
                foreach (string file in extra)
                {
                    bool tar  = false;
                    bool gzip = false;
                    var  ext  = Path.GetExtension(file).ToUpperInvariant();

                    switch (ext)
                    {
                    case ".TGZ":
                        tar  = true;
                        gzip = true;
                        break;

                    case ".GZ":
                        gzip = true;
                        tar  = file.EndsWith(".TAR.GZ");
                        break;

                    case ".TAR":
                        tar = true;
                        break;
                    }

                    try
                    {
                        Stream stream = File.OpenRead(file);
                        if (gzip)
                        {
                            stream = new GZipStream(stream, CompressionMode.Decompress);
                        }

                        if (tar)
                        {
                            using (var reader = new TarFile(stream))
                            {
                                Func <string, bool> isLikelyXmlFile =
                                    fn => 0 == String.Compare(Path.GetExtension(fn), ".XML", ignoreCase: true);

                                // Look through the TGZ/TAR.GZ file for any XML file
                                foreach (var entry in reader.EnumerateEntries(entry => isLikelyXmlFile(entry.Name)))
                                {
                                    Console.WriteLine("[Info] Extracting: {0}", entry.Name);
                                    var xdoc = XDocument.Load(reader.Current);
                                    if (xdoc.Descendants(ns + "parsedwaveforms").Any())
                                    {
                                        xdoc = UpdateFile(xdoc, config);

                                        var output = Path.ChangeExtension(Path.GetFileName(entry.Name), ".decomp.xml");
                                        Console.WriteLine("[Info] Saving: {0}", output);
                                        xdoc.Save(output);
                                    }
                                }
                            }
                        }
                        else
                        {
                            var xdoc = UpdateFile(XDocument.Load(stream), config);

                            var output = Path.ChangeExtension(Path.GetFileName(file), ".decomp.xml");
                            Console.WriteLine("[Info] Saving: {0}", output);
                            xdoc.Save(output);
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.Error.WriteLine("[Error] Could not decompress '{0}'", file);
                        Console.Error.WriteLine("{0}", ex);
                        Environment.ExitCode = -2;
                    }
                }
            }
        }