Listtree.mcc: implement proxying of DisplayHook
[AROS.git] / workbench / c / WBRun / main.c
blob6da37459aad3a9b20c19638a0070e2086f7b5f9a
1 /*
2 Copyright © 1995-2013, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: WBRun CLI command
6 Lang: English
7 */
10 #include <exec/types.h>
11 #include <dos/dos.h>
13 #include <proto/dos.h>
14 #include <proto/workbench.h>
15 #include <proto/utility.h>
17 #define DEBUG 0
18 #include <aros/debug.h>
20 #define SH_GLOBAL_DOSBASE TRUE
21 #include <aros/shcommands.h>
23 AROS_SH6H
25 WBRun, 44.1,
26 "Open/launch a workbench object as if its icon were double-clicked",
27 AROS_SHAH(STRPTR, , PROG, /A, "", "\tName of the object to be opened."),
28 AROS_SHAH(STRPTR *, , ARGS, /M, NULL,
29 "\tList of parameters (Workbench arguments) to pass to\n"
30 "\t\tthe tool/project to be launched."),
31 AROS_SHAH(STRPTR, , SHOW, /K, "",
32 "\tControls whether files and drawers without icons will be\n"
33 "\t\tshown (if a drawer is opened). Possible values are ICONS\n"
34 "\t\tor ALL. [unimplemented]"),
35 AROS_SHAH(STRPTR, , VIEWBY, /K, "",
36 "Viewing mode for a drawer. Possible values are ICON, NAME,\n"
37 "\t\tDATE or SIZE. [unimplemented]"),
38 AROS_SHAH(IPTR, , DELAY, /K/N, "",
39 "Seconds to wait before opening the object. [unimplemented]"),
40 AROS_SHAH(BOOL, , QUIET, /S, "",
41 "\tDo not show requesters if object is unavailable.\n"
42 "\t\t[unimplemented]")
45 AROS_SHCOMMAND_INIT
47 struct Library *WorkbenchBase = OpenLibrary("workbench.library", 44L);
48 struct Library *UtilityBase = OpenLibrary("utility.library", 41L);
49 struct TagItem *argsTagList = NULL;
50 BOOL success = FALSE;
51 int nbArgs = 0, i = 0;
52 STRPTR *wbArg;
54 if (WorkbenchBase != NULL)
56 if (SHArg(ARGS) != NULL)
58 if (UtilityBase != NULL)
60 for ( wbArg = SHArg(ARGS) ; *wbArg ; wbArg++, nbArgs++ )
62 D(bug("[WBRun] wbArg[%d] %s\n", nbArgs, *wbArg));
64 argsTagList = AllocateTagItems(nbArgs + 1);
65 for ( wbArg = SHArg(ARGS) ; *wbArg ; wbArg++, i++ )
67 argsTagList[i].ti_Tag = WBOPENA_ArgName;
68 argsTagList[i].ti_Data = (IPTR) *wbArg;
69 D(bug("[WBRun] argsTagList[%d]: %s\n", i, argsTagList[i].ti_Data));
71 argsTagList[i].ti_Tag = TAG_DONE;
72 D(bug("[WBRun] i = %d, nbArgs = %d\n", i, nbArgs));
73 success = OpenWorkbenchObjectA(SHArg(PROG), argsTagList);
74 FreeTagItems(argsTagList);
76 else
78 PutStr("ERROR: Could not open utility.library v41+.\n");
81 else
83 D(bug("[WBRun] SHArg(ARGS) == NULL\n"));
84 success = OpenWorkbenchObject(SHArg(PROG), TAG_DONE);
86 if (UtilityBase != NULL)
87 CloseLibrary(UtilityBase);
88 CloseLibrary(WorkbenchBase);
90 else
92 PutStr("ERROR: Could not open workbench.library v44+.\n");
95 return success ? RETURN_OK : RETURN_FAIL;
97 AROS_SHCOMMAND_EXIT