LCOV - code coverage report
Current view: top level - apps - gdalalg_info.cpp (source / functions) Hit Total Coverage
Test: gdal_filtered.info Lines: 9 9 100.0 %
Date: 2025-05-15 13:16:46 Functions: 2 2 100.0 %

          Line data    Source code
       1             : /******************************************************************************
       2             :  *
       3             :  * Project:  GDAL
       4             :  * Purpose:  gdal "info" subcommand
       5             :  * Author:   Even Rouault <even dot rouault at spatialys.com>
       6             :  *
       7             :  ******************************************************************************
       8             :  * Copyright (c) 2024, Even Rouault <even dot rouault at spatialys.com>
       9             :  *
      10             :  * SPDX-License-Identifier: MIT
      11             :  ****************************************************************************/
      12             : 
      13             : #include "cpl_error.h"
      14             : #include "gdalalgorithm.h"
      15             : #include "gdalalg_raster_info.h"
      16             : #include "gdalalg_vector_info.h"
      17             : #include "gdalalg_dispatcher.h"
      18             : #include "gdal_priv.h"
      19             : 
      20             : /************************************************************************/
      21             : /*                          GDALInfoAlgorithm                           */
      22             : /************************************************************************/
      23             : 
      24             : class GDALInfoAlgorithm final
      25             :     : public GDALDispatcherAlgorithm<GDALRasterInfoAlgorithm,
      26             :                                      GDALVectorInfoAlgorithm>
      27             : {
      28             :   public:
      29             :     static constexpr const char *NAME = "info";
      30             :     static constexpr const char *DESCRIPTION =
      31             :         "Return information on a dataset (shortcut for 'gdal raster info' or "
      32             :         "'gdal vector info').";
      33             :     static constexpr const char *HELP_URL = "/programs/gdal_info.html";
      34             : 
      35          24 :     GDALInfoAlgorithm() : GDALDispatcherAlgorithm(NAME, DESCRIPTION, HELP_URL)
      36             :     {
      37             :         // only for the help message
      38          24 :         AddOutputFormatArg(&m_format).SetDefault("json").SetChoices("json",
      39          24 :                                                                     "text");
      40          24 :         AddInputDatasetArg(&m_dataset);
      41             : 
      42             :         m_longDescription = "For all options, run 'gdal raster info --help' or "
      43          24 :                             "'gdal vector info --help'";
      44          24 :     }
      45             : 
      46             :   private:
      47             :     std::unique_ptr<GDALRasterInfoAlgorithm> m_rasterInfo{};
      48             :     std::unique_ptr<GDALVectorInfoAlgorithm> m_vectorInfo{};
      49             : 
      50             :     std::string m_format{};
      51             :     GDALArgDatasetValue m_dataset{};
      52             : 
      53           2 :     bool RunImpl(GDALProgressFunc, void *) override
      54             :     {
      55           2 :         CPLError(CE_Failure, CPLE_AppDefined,
      56             :                  "The Run() method should not be called directly on the \"gdal "
      57             :                  "info\" program.");
      58           2 :         return false;
      59             :     }
      60             : };
      61             : 
      62             : GDAL_STATIC_REGISTER_ALG(GDALInfoAlgorithm);

Generated by: LCOV version 1.14