CmdCustom: Respect report.<name>.context configuration variable

This allows the user to configure if a specific report should (or should
not) adhere to the currently active context.

Closes #2560.
This commit is contained in:
Tomas Babej 2021-08-20 20:17:50 -04:00
parent c195c59494
commit ab29ef8326
3 changed files with 17 additions and 1 deletions

View file

@ -59,6 +59,21 @@ CmdCustom::CmdCustom (
_category = Category::report; _category = Category::report;
} }
////////////////////////////////////////////////////////////////////////////////
// Whether a report uses context is defined by the report.<name>.context
// configuration variable.
//
bool CmdCustom::uses_context () const
{
auto config = Context::getContext ().config;
auto key = "report." + _keyword + ".context";
if (config.has (key))
return config.getBoolean (key);
else
return _uses_context;
}
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
int CmdCustom::execute (std::string& output) int CmdCustom::execute (std::string& output)
{ {

View file

@ -34,6 +34,7 @@ class CmdCustom : public Command
{ {
public: public:
CmdCustom (const std::string&, const std::string&, const std::string&); CmdCustom (const std::string&, const std::string&, const std::string&);
bool uses_context () const override;
int execute (std::string&); int execute (std::string&);
private: private:

View file

@ -63,7 +63,7 @@ public:
bool read_only () const; bool read_only () const;
bool displays_id () const; bool displays_id () const;
bool needs_gc () const; bool needs_gc () const;
bool uses_context () const; virtual bool uses_context () const;
bool accepts_filter () const; bool accepts_filter () const;
bool accepts_modifications () const; bool accepts_modifications () const;
bool accepts_miscellaneous () const; bool accepts_miscellaneous () const;