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 ////////////////////////////////////////////////////////////////////
17 int main (int argc
, char **argv
)
19 wprintf(L
"ReactOs PackageManager %d.%d.%d Commandline Interface \n\n", PACKMGR_VERSION_MAJOR
, PACKMGR_VERSION_MINOR
, PACKMGR_VERSION_PATCH_LEVEL
);
20 Argv
= argv
; Argc
= argc
;
26 if (!strcmp(argv
[1], "install"))
29 // install a package from source
30 else if (!strcmp(argv
[1], "src-inst"))
32 wprintf(L
"Sorry but I can't do that yet. \n");
36 else if (!strcmp(argv
[1], "update"))
38 wprintf(L
"Sorry but I can't do that yet. \n");
42 else if (!strcmp(argv
[1], "dist-upgrade"))
44 wprintf(L
"Sorry but I can't do that yet. \n");
48 else if (!strcmp(argv
[1], "remove"))
50 wprintf(L
"Sorry but I can't do that yet. \n");
53 // search for a package
54 else if (!strcmp(argv
[1], "show"))
59 // search for a package
60 else if (!strcmp(argv
[1], "search"))
62 wprintf(L
"Sorry but I can't do that yet. \n");
77 wprintf(L
"Usage: ros-get [command] \n\n");
79 wprintf(L
"Possible commands: \n");
80 wprintf(L
" install [package name] \t Installs a package \n\n");
81 wprintf(L
" show [package name] \t\t Shows you detailed information about a package \n");
83 wprintf(L
"Currently unimplemented commands: \n");
84 wprintf(L
" src-install [package name] \t Installs a package from source code \n");
85 wprintf(L
" update [package name] \t Updates a package \n");
86 wprintf(L
" dist-update [package name] \t Updates a package \n");
87 wprintf(L
" remove [package name] \t Uninstalls a package \n\n");
89 wprintf(L
" search [search agrument] \t Finds a package \n");
90 wprintf(L
" list \t\t\t\t Lists all installed programs \n");
95 int Ask (const WCHAR
* question
)
98 wprintf(L
"%s [y/n] ", question
);
99 char answer
= getchar();
102 while(getchar()!='\n');
109 else if (answer
== 'n')
112 return Ask(question
);
115 int SetStatus (int status1
, int status2
, WCHAR
* text
)
118 wprintf(L
"%s\n", text
);
120 // If the Status is 1000 things are done
123 wprintf(L
"%s\n", PML_TransError(status2
));
136 error
= PML_LoadTree (&tree
, "tree.xml", NULL
);
139 wprintf(PML_TransError(error
));
144 for (i
=2; i
<Argc
; i
++)
146 int id
= PML_FindItem(tree
, Argv
[i
]);
150 PML_LoadPackage(tree
, id
, NULL
);
151 PML_SetAction(tree
, id
, 1, NULL
, Ask
);
155 printf("Could not find the Package \"%s\"\n", Argv
[i
]);
159 error
= PML_DoIt (tree
, SetStatus
, Ask
);
162 wprintf(PML_TransError(error
));
163 PML_CloseTree (tree
);
172 PML_CloseTree (tree
);
183 error
= PML_LoadTree (&tree
, "tree.xml", NULL
);
186 wprintf(PML_TransError(error
));
191 for (i
=2; i
<Argc
; i
++)
193 int id
= PML_FindItem(tree
, Argv
[i
]);
196 printf(PML_GetDescription(tree
, id
));
199 printf("Could not find the Package \"%s\"\n", Argv
[i
]);
203 PML_CloseTree (tree
);