public static int MainWithOpts(ProgOptions options)
        {
            var inputStream = GetInputStream(options);

            // Parse the input stream
            var entity = EntityRepository.Decode(inputStream);

            if (entity.IsCollection())
            {
                (entity as EntityCollection).WriteDecodedToFolder(options.output);
            }
            else
            {
                var outputStream = GetOutputStream(options);

                entity.WriteDecodedToStream(outputStream);

                outputStream.Close();
            }

            inputStream.Close();

            return(0);
        }