Skip to content

Commit 2c515b6

Browse files
committed
Examples as single file packages. Remove dub.selections.json
1 parent 550210a commit 2c515b6

20 files changed

+43
-143
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ bin/
1212
lib/
1313
docs/
1414
*.lst
15+
dub.selections.json

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,41 +27,41 @@ Note: detection of file MIME type is out of the scope of **mimeapps**. You may c
2727

2828
## Examples
2929

30-
### [Mimeapps list](examples/list/source/app.d)
30+
### [Mimeapps list](examples/list.d)
3131

3232
List default application and other associated applications for MIME type(s):
3333

34-
dub run :list -- text/plain image/png text/html
34+
dub examples/list.d text/plain image/png text/html
3535

3636
Also can be used for uri schemes:
3737

38-
dub run :list -- x-scheme-handler/http
38+
dub examples/list.d x-scheme-handler/http
3939

40-
### [Mimeapps test](examples/test/source/app.d)
40+
### [Mimeapps test](examples/test.d)
4141

4242
Parse all mimeapps.list and mimeinfo.cache found on the system. Reports errors to stderr.
4343
Use this example to check if the mimeapps library can parse all related files on your system.
4444

45-
dub run :test
45+
dub examples/test.d
4646

4747
### [Mimeapps open](examples/open/source/app.d)
4848

4949
Detect MIME type of file and open it with default application for found type.
5050

51-
dub run :open -- LICENSE_1_0.txt
51+
dub examples/open.d LICENSE_1_0.txt
5252

5353
Add option --ask to list all associated applications before opening the file.
5454

55-
dub run :open -- --ask LICENSE_1_0.txt
55+
dub examples/open.d --ask LICENSE_1_0.txt
5656

5757
Pass http url to open in web browser:
5858

59-
dub run :open -- --ask https://github.com/FreeSlave/mimeapps
59+
dub examples/open.d --ask https://github.com/FreeSlave/mimeapps
6060

6161
### [Mimeapps update](examples/update/source/app.d)
6262

6363
Update mimeapps.list file. Since this library is in development, don't use this example to update file associations on your system.
64-
Better make copy first.
64+
Better make a copy first.
6565

6666
cp $HOME/.config/mimeapps.list /tmp/mimeapps.list
67-
dub run :update -- --file=/tmp/mimeapps.list --remove=text/plain:kde4-kwrite.desktop --add=image/jpeg:gthumb.desktop --default=application/pdf:kde4-okular.desktop
67+
dub examples/update.d --file=/tmp/mimeapps.list --remove=text/plain:kde4-kwrite.desktop --add=image/jpeg:gthumb.desktop --default=application/pdf:kde4-okular.desktop

dub.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,10 @@
55
"copyright": "Copyright © 2016, Roman Chistokhodov",
66
"authors": ["Roman Chistokhodov"],
77
"dependencies": {
8-
"desktopfile" : "~>1.1.0"
8+
"desktopfile" : "~>1.2.0"
99
},
1010
"targetName" : "mimeapps",
1111
"targetPath" : "lib",
1212
"targetType" : "library",
13-
"versions" : ["mimeappsFileTest"],
14-
"subPackages" : ["./examples/list", "./examples/test", "./examples/open", "./examples/update"]
13+
"versions" : ["mimeappsFileTest"]
1514
}

dub.selections.json

Lines changed: 0 additions & 11 deletions
This file was deleted.

examples/list/source/app.d renamed to examples/list.d

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/+dub.sdl:
2+
name "list"
3+
dependency "mimeapps" path="../"
4+
+/
5+
16
import std.stdio;
27
import std.algorithm : map;
38

examples/list/.gitignore

Lines changed: 0 additions & 5 deletions
This file was deleted.

examples/list/dub.json

Lines changed: 0 additions & 11 deletions
This file was deleted.

examples/list/dub.selections.json

Lines changed: 0 additions & 11 deletions
This file was deleted.

examples/open/source/app.d renamed to examples/open.d

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
/+dub.sdl:
2+
name "open"
3+
dependency "mimeapps" path="../"
4+
dependency "mime" version="~>0.4.3"
5+
+/
6+
17
import std.stdio;
28
import std.getopt;
39
import std.string : stripRight, startsWith;

examples/open/.gitignore

Lines changed: 0 additions & 5 deletions
This file was deleted.

examples/open/dub.json

Lines changed: 0 additions & 12 deletions
This file was deleted.

examples/open/dub.selections.json

Lines changed: 0 additions & 12 deletions
This file was deleted.

examples/test/source/app.d renamed to examples/test.d

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/+dub.sdl:
2+
name "test"
3+
dependency "mimeapps" path="../"
4+
+/
5+
16
import std.stdio;
27
import std.algorithm;
38
import std.file;

examples/test/.gitignore

Lines changed: 0 additions & 5 deletions
This file was deleted.

examples/test/dub.json

Lines changed: 0 additions & 11 deletions
This file was deleted.

examples/test/dub.selections.json

Lines changed: 0 additions & 11 deletions
This file was deleted.

examples/update/source/app.d renamed to examples/update.d

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/+dub.sdl:
2+
name "update"
3+
dependency "mimeapps" path="../"
4+
+/
5+
16
import std.stdio;
27
import std.getopt;
38
import std.string;
@@ -23,51 +28,51 @@ int main(string[] args)
2328
"remove", "Remove association", &toRemove,
2429
"default", "Set default application", &toSetDefault
2530
);
26-
31+
2732
if (fileName.empty) {
2833
stderr.writeln("No input file given");
2934
return 1;
3035
}
31-
36+
3237
if (toAdd.empty && toRemove.empty && toSetDefault.empty) {
3338
stderr.writeln("No update operations given");
3439
return 1;
3540
}
36-
41+
3742
AssociationUpdateQuery query;
38-
43+
3944
foreach(str; toRemove) {
4045
auto splitted = str.findSplit(":");
4146
if (splitted[1].empty) {
4247
return assocFormatError();
4348
}
4449
query.removeAssociation(splitted[0], splitted[2]);
4550
}
46-
51+
4752
foreach(str; toAdd) {
4853
auto splitted = str.findSplit(":");
4954
if (splitted[1].empty) {
5055
return assocFormatError();
5156
}
5257
query.addAssociation(splitted[0], splitted[2]);
5358
}
54-
59+
5560
foreach(str; toSetDefault) {
5661
auto splitted = str.findSplit(":");
5762
if (splitted[1].empty) {
5863
return assocFormatError();
5964
}
6065
query.setDefaultApplication(splitted[0], splitted[2]);
6166
}
62-
67+
6368
static if (isFreedesktop) {
6469
auto mimeAppsLists = mimeAppsListPaths();
6570
if (mimeAppsLists.canFind(buildNormalizedPath(fileName))) {
66-
stderr.writeln("Cowardly refuse to update system file. Make a copy in other path.");
71+
stderr.writeln("Cowardly refusing to update a system file. Make a copy in other path.");
6772
return 1;
6873
}
6974
}
70-
75+
7176
updateAssociations(fileName, query);
7277
return 0;
7378
}

examples/update/.gitignore

Lines changed: 0 additions & 5 deletions
This file was deleted.

examples/update/dub.json

Lines changed: 0 additions & 11 deletions
This file was deleted.

examples/update/dub.selections.json

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)