1 ////////////////////////////////////////////////////////
5 // Implementation of a Commandlne Interface
6 // for the ReactOs Package Manager
8 // Maarten Bosma, 09.01.2004
9 // maarten.paul@bosma.de
11 ////////////////////////////////////////////////////////////////////
16 int main (int argc
, char **argv
)
18 cout
<< "ReactOs PackageManager " << PACKMGR_VERSION_MAJOR
<< "." << PACKMGR_VERSION_MINOR
<< "." << PACKMGR_VERSION_PATCH_LEVEL
<< " Commandline Interface \n\n";
25 for (i
=1; i
<argc
; i
++)
26 cmdline
.push_back(argv
[i
]);
29 if (cmdline
[0] == "install")
32 // install a package from source
33 else if (cmdline
[0] == "src-inst")
35 cout
<< "Sorry but I can't do that yet. \n";
39 else if (cmdline
[0] == "update")
41 cout
<< "Sorry but I can't do that yet. \n";
45 else if (cmdline
[0] == "dist-upgrade")
47 cout
<< "Sorry but I can't do that yet. \n";
51 else if (cmdline
[0] == "remove")
53 cout
<< "Sorry but I can't do that yet. \n";
56 // search for a package
57 else if (cmdline
[0] == "show")
62 // search for a package
63 else if (cmdline
[0] == "search")
65 cout
<< "Sorry but I can't do that yet. \n";
76 cout
<< "Usage: ros-get [command] \n\n";
78 cout
<< "Possible commands: \n";
79 cout
<< " install [package name] \t Installs a package \n\n";
80 cout
<< " show [package name] \t\t Shows you detailed information about a package \n";
82 cout
<< "Currently unimplemented commands: \n";
83 cout
<< " src-install [package name] \t Installs a package from source code \n";
84 cout
<< " update [package name] \t Updates a package \n";
85 cout
<< " dist-update [package name] \t Updates a package \n";
86 cout
<< " remove [package name] \t Uninstalls a package \n\n";
88 cout
<< " search [search agrument] \t Finds a package \n";
89 cout
<< " list \t\t\t\t Lists all installed programs \n\n";
94 int Ask (const WCHAR
* question
)
107 else if (answer
[0]=='n')
110 return Ask(question
);
113 int SetStatus (int status1
, int status2
, WCHAR
* text
)
116 wprintf(L
"%s\n", text
);
118 // If the Status is 1000 things are done
121 wprintf(L
"%s\n", PML_TransError(status2
));
134 error
= PML_LoadTree (&tree
, "tree.xml", NULL
);
137 cout
<< PML_TransError(error
);
142 for (i
=1; (UINT
)i
<cmdline
.size(); i
++)
144 int id
= PML_FindItem(tree
, cmdline
[i
].c_str());
147 PML_SetAction(tree
, id
, 1, NULL
, Ask
);
150 cout
<< "Could not find the Package \"" << cmdline
[i
] << "\"\n";
154 error
= PML_DoIt (tree
, SetStatus
, Ask
);
157 wprintf(L
"%s\n", PML_TransError(error
));
158 PML_CloseTree (tree
);
167 PML_CloseTree (tree
);
178 error
= PML_LoadTree (&tree
, "tree.xml", NULL
);
181 cout
<< PML_TransError(error
);
186 for (i
=1; (UINT
)i
<cmdline
.size(); i
++)
188 int id
= PML_FindItem(tree
, cmdline
[i
].c_str());
191 cout
<< PML_GetDescription (tree
, id
) << "\n";
194 cout
<< "Could not find the Package \"" << cmdline
[i
] << "\"\n";
198 PML_CloseTree (tree
);