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 78 : 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 39 : GDALInfoAlgorithm() : GDALDispatcherAlgorithm(NAME, DESCRIPTION, HELP_URL) 36 : { 37 : // only for the help message 38 39 : AddOutputFormatArg(&m_format).SetChoices("json", "text"); 39 39 : AddInputDatasetArg(&m_dataset); 40 : 41 : m_longDescription = "For all options, run 'gdal raster info --help' or " 42 39 : "'gdal vector info --help'"; 43 39 : } 44 : 45 : ~GDALInfoAlgorithm() override; 46 : 47 : private: 48 : std::string m_format{}; 49 : GDALArgDatasetValue m_dataset{}; 50 : 51 2 : bool RunImpl(GDALProgressFunc, void *) override 52 : { 53 2 : CPLError(CE_Failure, CPLE_AppDefined, 54 : "The Run() method should not be called directly on the \"gdal " 55 : "info\" program."); 56 2 : return false; 57 : } 58 : }; 59 : 60 : GDALInfoAlgorithm::~GDALInfoAlgorithm() = default; 61 : 62 : GDAL_STATIC_REGISTER_ALG(GDALInfoAlgorithm);