LCOV - code coverage report
Current view: top level - apps - gdalalg_info.cpp (source / functions) Hit Total Coverage
Test: gdal_filtered.info Lines: 11 11 100.0 %
Date: 2025-01-18 12:42:00 Functions: 3 3 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        1414 :     static std::vector<std::string> GetAliases()
      36             :     {
      37        1414 :         return {};
      38             :     }
      39             : 
      40          23 :     GDALInfoAlgorithm() : GDALDispatcherAlgorithm(NAME, DESCRIPTION, HELP_URL)
      41             :     {
      42             :         // only for the help message
      43          23 :         AddOutputFormatArg(&m_format).SetDefault("json").SetChoices("json",
      44          23 :                                                                     "text");
      45          23 :         AddInputDatasetArg(&m_dataset);
      46             : 
      47             :         m_longDescription = "For all options, run 'gdal raster info --help' or "
      48          23 :                             "'gdal vector info --help'";
      49          23 :     }
      50             : 
      51             :   private:
      52             :     std::unique_ptr<GDALRasterInfoAlgorithm> m_rasterInfo{};
      53             :     std::unique_ptr<GDALVectorInfoAlgorithm> m_vectorInfo{};
      54             : 
      55             :     std::string m_format{};
      56             :     GDALArgDatasetValue m_dataset{};
      57             : 
      58           2 :     bool RunImpl(GDALProgressFunc, void *) override
      59             :     {
      60           2 :         CPLError(CE_Failure, CPLE_AppDefined,
      61             :                  "The Run() method should not be called directly on the \"gdal "
      62             :                  "info\" program.");
      63           2 :         return false;
      64             :     }
      65             : };
      66             : 
      67             : GDAL_STATIC_REGISTER_ALG(GDALInfoAlgorithm);

Generated by: LCOV version 1.14