1 ////////////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright 2006 - 2021, Tomas Babej, Paul Beckingham, Federico Hernandez.
4 //
5 // Permission is hereby granted, free of charge, to any person obtaining a copy
6 // of this software and associated documentation files (the "Software"), to deal
7 // in the Software without restriction, including without limitation the rights
8 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 // copies of the Software, and to permit persons to whom the Software is
10 // furnished to do so, subject to the following conditions:
11 //
12 // The above copyright notice and this permission notice shall be included
13 // in all copies or substantial portions of the Software.
14 //
15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 // SOFTWARE.
22 //
23 // https://www.opensource.org/licenses/mit-license.php
24 //
25 ////////////////////////////////////////////////////////////////////////////////
26 
27 #include <cmake.h>
28 #include <CmdAttributes.h>
29 #include <sstream>
30 #include <algorithm>
31 #include <Context.h>
32 #include <Command.h>
33 
34 ////////////////////////////////////////////////////////////////////////////////
CmdZshAttributes()35 CmdZshAttributes::CmdZshAttributes ()
36 {
37   _keyword               = "_zshattributes";
38   _usage                 = "task          _zshattributes";
39   _description           = "Generates a list of all attributes, for zsh autocompletion purposes";
40   _read_only             = true;
41   _displays_id           = false;
42   _needs_gc              = false;
43   _uses_context          = false;
44   _accepts_filter        = false;
45   _accepts_modifications = false;
46   _accepts_miscellaneous = false;
47   _category              = Command::Category::internal;
48 }
49 
50 ////////////////////////////////////////////////////////////////////////////////
execute(std::string & output)51 int CmdZshAttributes::execute (std::string& output)
52 {
53   // Get a list of all columns, sort them.
54   auto columns = Context::getContext ().getColumns ();
55   std::sort (columns.begin (), columns.end ());
56 
57   std::stringstream out;
58   for (const auto& col : columns)
59     out << col << ':' << col << '\n';
60 
61   output = out.str ();
62   return 0;
63 }
64 
65 ////////////////////////////////////////////////////////////////////////////////
66