11#include " manifest.hpp"
2+
23#include < algorithm>
34#include < cctype>
45#include < vector>
56
67#include " libcufetch/common.hh"
78#include " util.hpp"
89
9- static bool validManifestName (const std::string_view n) {
10- return std::ranges::all_of (n, [](const unsigned char c) { return (isalnum (c) || c == ' -' || c == ' _' || c == ' =' ); });
10+ static bool validManifestName (const std::string_view n)
11+ {
12+ return std::ranges::all_of (n,
13+ [](const unsigned char c) { return (isalnum (c) || c == ' -' || c == ' _' || c == ' =' ); });
1114}
1215
1316CManifest::CManifest (const std::string_view path) : m_is_state(false )
@@ -21,48 +24,48 @@ CManifest::CManifest(const std::string_view path) : m_is_state(false)
2124 die (_ (" Failed to parse state file at '{}':\n "
2225 " {}\n "
2326 " \t (error occurred at line {} column {})" ),
24- path, err.description (),
25- err.source ().begin .line , err.source ().begin .column );
27+ path, err.description (), err.source ().begin .line , err.source ().begin .column );
2628 }
2729}
2830
29- std::vector<manifest_t > CManifest::get_all_plugins ()
31+ std::vector<plugin_t > CManifest::get_all_plugins ()
3032{
31- std::vector<manifest_t > plugins;
33+ std::vector<plugin_t > plugins;
3234 for (auto const & [name, _] : m_tbl)
3335 {
3436 if (name.str () == " repository" )
3537 continue ;
3638
3739 if (!validManifestName (name.str ()))
3840 {
39- warn (" Plugin '{}' has an invalid name. Only alphanumeric and '-', '_', '=' are allowed in the name" , name.str ());
41+ warn (" Plugin '{}' has an invalid name. Only alphanumeric and '-', '_', '=' are allowed in the name" ,
42+ name.str ());
4043 continue ;
4144 }
4245
43- plugins.push_back ({
44- name. data ( ),
45- getValue<std::string>(name, " license" ),
46- getValue<std::string> (name, " description " ),
47- getValue<std::string> (name, " output-dir " ),
48- getValueArrayStr (name, " authors" ),
49- getValueArrayStr (name, " build-steps" ),
50- });
46+ plugins.push_back ({ . name = name. data (),
47+ . description = getValue<std::string>(name, " description " ),
48+ . output_dir = getValue<std::string>(name, " license" ),
49+ . licenses = getValueArrayStr (name, " licenses " ),
50+ . conflicts = getValueArrayStr (name, " conflicts " ),
51+ . authors = getValueArrayStr (name, " authors" ),
52+ . build_steps = getValueArrayStr (name, " build-steps" ),
53+ . prefixes = getValueArrayStr (name, " prefixes " ) });
5154 }
5255 return plugins;
5356}
5457
55- manifest_t CManifest::get_plugin (const std::string_view name)
58+ plugin_t CManifest::get_plugin (const std::string_view name)
5659{
5760 if (!m_tbl[name].is_table ())
5861 die (" Couldn't find such plugin '{}' in manifest" , name);
5962
60- return {
61- name. data ( ),
62- getValue<std::string>(name, " license" ),
63- getValue<std::string> (name, " description " ),
64- getValue<std::string> (name, " output-dir " ),
65- getValueArrayStr (name, " authors" ),
66- getValueArrayStr (name, " build-steps" ),
67- };
63+ return { . name = name. data (),
64+ . description = getValue<std::string>(name, " description " ),
65+ . output_dir = getValue<std::string>(name, " license" ),
66+ . licenses = getValueArrayStr (name, " licenses " ),
67+ . conflicts = getValueArrayStr (name, " conflicts " ),
68+ . authors = getValueArrayStr (name, " authors" ),
69+ . build_steps = getValueArrayStr (name, " build-steps" ),
70+ . prefixes = getValueArrayStr (name, " prefixes " ) };
6871}
0 commit comments