Skip to content

Commit 9434629

Browse files
committed
Document --search option in readme and add version number option
1 parent f9e93b0 commit 9434629

File tree

5 files changed

+105
-24
lines changed

5 files changed

+105
-24
lines changed

README.md

Lines changed: 48 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#Overview
1+
# Overview
22
The D Completion Daemon is an auto-complete program for the D programming language.
33

44
![Teaser](teaser.png "This is what the future looks like - Jayce, League of Legends")
@@ -13,7 +13,7 @@ used through a text editor script or plugin, though it can be used from the
1313
command line. The server (dcd-server) is responsible for caching imported files,
1414
calculating autocomplete information, and sending it back to the client.
1515

16-
#Status
16+
# Status
1717
This program is reasonably stable. Please report problems on the Github issue
1818
tracker. Please be sure that you have read the documentation before filing an
1919
issue.
@@ -31,25 +31,25 @@ issue.
3131
* Display of documentation comments in function call tips
3232
* *alias this*
3333
* *auto* declarations (Mostly)
34+
* *with* statements
3435
* Not working:
35-
* Automatic starting of the server by the client
3636
* UFCS suggestions
3737
* Autocompletion of declarations with template arguments (This will work to some extent, but it won't do things like replace T with int)
3838
* Determining the type of an enum member when no base type is specified, but the first member has an initialaizer
3939
* That one feature that you *REALLY* needed
4040

41-
#Setup
41+
# Setup
4242
1. Install a recent D compiler. DCD is tested with 2.066 and LDC 0.14.0.
4343
1. Run ```git submodule update --init``` after cloning this repository to grab the MessagePack and Datapacked libraries and the parser from DScanner.
4444
1. Run ```make``` to build the client and server. (Or run build.bat on Windows). ```make ldc``` and ```make gdc``` will use the LDC or GDC compilers. The resulting executable will be much faster.
4545
1. Configure your text editor to call the dcd-client program. See the *editors* folder for directions on configuring your specific editor.
4646
1. Start the dcd-server program before editing code. (Unless, of course, your editor's plugin handles this for you)
4747

48-
#Client
48+
# Client
4949
Because DCD is designed to be used from a text editor, this section is written
5050
primarily for plugin authors.
5151

52-
##Get autocomplete information
52+
## Get autocomplete information
5353
The primary use case of the client is to query the server for autocomplete information.
5454
To do this, provide the client with the file that the user is editing along with the
5555
cursor position (in bytes).
@@ -63,14 +63,14 @@ a left parethesis.
6363

6464
The file name is optional. If it is not specified, input will be read from *stdin*.
6565

66-
###Dot completion
66+
### Dot completion
6767
When the first line of output is "identifiers", the editor should display a
6868
completion list.
69-
####Output format
69+
#### Output format
7070
A line containing the string "identifiers" followed by the completions that are
7171
available, one per line. Each line consists of the completion name followed by a
7272
tab character, followed by a completion kind
73-
#####Completion kinds
73+
##### Completion kinds
7474
* c - class name
7575
* i - interface name
7676
* s - struct name
@@ -89,7 +89,7 @@ tab character, followed by a completion kind
8989
* t - template name
9090
* T - mixin template name
9191

92-
####Example output
92+
#### Example output
9393
identifiers
9494
parts v
9595
name v
@@ -101,18 +101,18 @@ tab character, followed by a completion kind
101101
calltip v
102102
getPartByName f
103103

104-
####Note
104+
#### Note
105105
DCD's output will start with "identifiers" when completing at a left paren
106106
character if the keywords *pragma*, *scope*, *__traits*, *extern*, or *version*
107107
were just before the paren.
108108

109-
###Parenthesis completion
109+
### Parenthesis completion
110110
When the first line of output is "calltips", the editor should display a function
111111
call tip.
112-
#####Output format
112+
##### Output format
113113
A line containing the string "calltips", followed by zero or more lines, each
114114
containing a call tip for an overload of the given function.
115-
#####Example output
115+
##### Example output
116116
calltips
117117
ACSymbol findSymbolInCurrentScope(size_t cursorPosition, string name)
118118

@@ -123,21 +123,21 @@ comments associated with the symbol at the cursor position. In the case of
123123
functions there can be more than one documentation comment associated with a
124124
symbol. One doc comment will be printed per line. Newlines within the doc
125125
comments will be replaced with "\n".
126-
####Example output
126+
#### Example output
127127
An example doc comment\nParams: a = first param\n Returns: nothing
128128
An example doc comment\nParams: a = first param\n b = second param\n Returns: nothing
129129

130-
##Clear server's autocomplete cache
130+
## Clear server's autocomplete cache
131131
```dcd-client --clearCache```
132132

133-
##Add import search path
133+
## Add import search path
134134
Import paths can be added to the server without restarting it. To accomplish
135135
this, run the client with the -I option:
136136

137137
dcd-client -Ipath/to/imports
138138

139139

140-
##Find declaration of symbol at cursor
140+
## Find declaration of symbol at cursor
141141
```dcd-client --symbolLocation -c 123```
142142

143143
The "--symbolLocation" or "-l" flags cause the client to instruct the server
@@ -149,6 +149,36 @@ followed by the byte offset, followed by a newline character. For example:
149149

150150
/home/example/src/project/bar.d 3482
151151

152+
## Search for symbols by name
153+
154+
The "--search" or "-s" option causes the server to return location information
155+
for all symbols with the given name in both the file being edited as well as
156+
the server cache. The output format is one result per line, with the path, the
157+
symbol type, and the byte offset of the symbol separated by tab characters.
158+
159+
### Example
160+
161+
Search the server's cache for symbols named "toImpl". (Using echo to give an EOF
162+
in place of a file being edited.)
163+
```echo | dcd-client --search toImpl``
164+
165+
```
166+
/usr/include/dmd/phobos/std/conv.d f 48491
167+
/usr/include/dmd/phobos/std/conv.d f 47527
168+
/usr/include/dmd/phobos/std/conv.d f 47229
169+
/usr/include/dmd/phobos/std/conv.d f 40358
170+
/usr/include/dmd/phobos/std/conv.d f 38348
171+
/usr/include/dmd/phobos/std/conv.d f 35619
172+
/usr/include/dmd/phobos/std/conv.d f 32743
173+
/usr/include/dmd/phobos/std/conv.d f 22486
174+
/usr/include/dmd/phobos/std/conv.d f 16322
175+
/usr/include/dmd/phobos/std/conv.d f 14829
176+
/usr/include/dmd/phobos/std/conv.d f 14066
177+
/usr/include/dmd/phobos/std/conv.d f 13058
178+
/usr/include/dmd/phobos/std/conv.d f 12717
179+
/usr/include/dmd/phobos/std/conv.d f 9494
180+
```
181+
152182
#Server
153183
The server must be running for the DCD client to provide autocomplete information.
154184
In future versions the client may start the server if it is not running, but for

makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ clean:
2121
CLIENT_SRC = src/client.d\
2222
src/messages.d\
2323
src/stupidlog.d\
24+
src/dcd_version.d\
2425
msgpack-d/src/msgpack.d
2526

2627
DMD_CLIENT_FLAGS = -Imsgpack-d/src\
@@ -57,6 +58,7 @@ SERVER_SRC = src/actypes.d\
5758
src/server.d\
5859
src/stupidlog.d\
5960
src/string_interning.d\
61+
src/dcd_version.d\
6062
libdparse/src/std/d/ast.d\
6163
libdparse/src/std/d/entities.d\
6264
libdparse/src/std/d/lexer.d\

src/client.d

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import std.string;
3232
import msgpack;
3333
import messages;
3434
import stupidlog;
35+
import dcd_version;
3536

3637
int main(string[] args)
3738
{
@@ -44,14 +45,16 @@ int main(string[] args)
4445
bool symbolLocation;
4546
bool doc;
4647
bool query;
48+
bool printVersion;
4749
string search;
4850

4951
try
5052
{
5153
getopt(args, "cursorPos|c", &cursorPos, "I", &importPaths,
5254
"port|p", &port, "help|h", &help, "shutdown", &shutdown,
5355
"clearCache", &clearCache, "symbolLocation|l", &symbolLocation,
54-
"doc|d", &doc, "query|q", &query, "search|s", &search);
56+
"doc|d", &doc, "query|q", &query, "search|s", &search,
57+
"version", &printVersion);
5558
}
5659
catch (Exception e)
5760
{
@@ -61,7 +64,13 @@ int main(string[] args)
6164

6265
AutocompleteRequest request;
6366

64-
if (help)
67+
68+
if (printVersion)
69+
{
70+
writeln(DCD_VERSION);
71+
return 0;
72+
}
73+
else if (help)
6574
{
6675
printHelp(args[0]);
6776
return 0;
@@ -227,10 +236,13 @@ Options:
227236
Query the server statis. Returns 0 if the server is running. Returns
228237
1 if the server could not be contacted.
229238
230-
-IPATH
239+
-I PATH
231240
Instructs the server to add PATH to its list of paths searced for
232241
imported modules.
233242
243+
--version
244+
Prints the version number and then exits.
245+
234246
--port PORTNUMBER | -p PORTNUMBER
235247
Uses PORTNUMBER to communicate with the server instead of the default
236248
port 9166.`, programName);

src/dcd_version.d

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
2+
* This file is part of DCD, a development tool for the D programming language.
3+
* Copyright (C) 2014 Brian Schott
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU General Public License
16+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
17+
*/
18+
19+
module dcd_version;
20+
21+
enum DCD_VERSION = "v0.4.0-beta2";

src/server.d

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import modulecache;
4040
import stupidlog;
4141
import actypes;
4242
import core.memory;
43+
import dcd_version;
4344

4445
enum CONFIG_FILE_NAME = "dcd.conf";
4546

@@ -58,11 +59,13 @@ int main(string[] args)
5859

5960
ushort port = 9166;
6061
bool help;
62+
bool printVersion;
6163
string[] importPaths;
6264

6365
try
6466
{
65-
getopt(args, "port|p", &port, "I", &importPaths, "help|h", &help);
67+
getopt(args, "port|p", &port, "I", &importPaths, "help|h", &help,
68+
"version", & printVersion);
6669
}
6770
catch (ConvException e)
6871
{
@@ -71,6 +74,12 @@ int main(string[] args)
7174
return 1;
7275
}
7376

77+
if (printVersion)
78+
{
79+
writeln(DCD_VERSION);
80+
return 0;
81+
}
82+
7483
if (help)
7584
{
7685
printHelp(args[0]);
@@ -277,8 +286,15 @@ void printHelp(string programName)
277286
Usage: %s options
278287
279288
options:
280-
-I path
281-
Includes path in the listing of paths that are searched for file imports
289+
-I PATH
290+
Includes PATH in the listing of paths that are searched for file
291+
imports.
292+
293+
--help | -h
294+
Prints this help message.
295+
296+
--version
297+
Prints the version number and then exits.
282298
283299
--port PORTNUMBER | -pPORTNUMBER
284300
Listens on PORTNUMBER instead of the default port 9166.`, programName);

0 commit comments

Comments
 (0)