Skip to content

Commit

Permalink
Rename sync to init\n\nThis better fits the meaning
Browse files Browse the repository at this point in the history
  • Loading branch information
Timoses committed Dec 11, 2018
1 parent 76a1066 commit 642b79c
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 19 deletions.
10 changes: 5 additions & 5 deletions README.md
Expand Up @@ -40,7 +40,7 @@ dub build --build=release
Get DotfiM started with

```
dotfim sync <gitRepo>
dotfim init <gitRepo>
```

Add a dotfile to be managed by DotfiM
Expand All @@ -66,14 +66,14 @@ What's a [gitfile and dotfile](#gitfile-and-dotfile)?
Pull from remote gitRepo, check for changes, update dotfiles and gitfiles and eventually commit local changes and push to remote.

----
**`dotfim sync <gitRepo>`**
**`dotfim init <gitRepo>`**

Create a folder for the git repository and run `dotfim`.

----
**`dotim add <dotfile1> <dotfile2> ... <dotfileN>`**

Add a dotfile to gitRepo. The file does not need to exist locally, but requires to be based upon the dotfiles path (specified during `dotfim sync` and stored in dotfim.json). Added dotfiles will be managed by DotfiM when running other commands (e.g. `dotfim`).
Add a dotfile to gitRepo. The file does not need to exist locally, but requires to be based upon the dotfiles path (specified during `dotfim init` and stored in dotfim.json). Added dotfiles will be managed by DotfiM when running other commands (e.g. `dotfim`).

----
**`dotfim remove <dotfile1> <dotfile2> ... <dotfileN>`**
Expand All @@ -97,15 +97,15 @@ Creates a playground test environment for experimentation under the path `direct
* `<dir>/dot/`: Simulated home folder
* `<dir>/repo.git`: Simulated remote git repository

Run `cd <dir> && dotfim sync repo.git` to get started.
Run `cd <dir> && dotfim init repo.git` to get started.


## Insights

Read more about the internal workings of DotfiM here.

### `dotfim.json` settings file
DotfiM requires a settings file `dotfim.json` containing information about the locations of your home folder and the local git repository folder and further stores the remote git repository url. To initially create this file run `dotfim sync`.
DotfiM requires a settings file `dotfim.json` containing information about the locations of your home folder and the local git repository folder and further stores the remote git repository url. To initially create this file run `dotfim init`.

### gitfile and dotfile
DotfiM differentiates between `gitfile` and `dotfile`. `gitfile` relates to the file in the git repository while `dotfile` relates to the file in your home folder.
Expand Down
8 changes: 4 additions & 4 deletions source/dotfim/cmd/sync.d → source/dotfim/cmd/init.d
@@ -1,4 +1,4 @@
module dotfim.cmd.sync;
module dotfim.cmd.init;

import std.algorithm : canFind;
import std.exception : enforce;
Expand All @@ -8,15 +8,15 @@ import std.stdio : writeln, readln, write;
import dotfim.dotfim;
import dotfim.util.ui;

struct Sync
struct Init
{
string gitRepo;
string dir;

this(string dir, string[] args = null)
{
import std.exception : enforce;
enforce(args, "Usage: dotfim sync <repoURL>");
enforce(args, "Usage: dotfim init <repoURL>");

this.dir = dir;

Expand Down Expand Up @@ -120,7 +120,7 @@ struct Sync
string question =
"DotfiM is already set up to sync with the following settings:\n"
~ "\t" ~ settings.internal.to!string ~ "\n"
~ "Syncing will delete old setup. Continue? (y/n): ";
~ "Initializing will delete old setup. Continue? (y/n): ";

import std.exception : enforce;
enforce(askContinue(question, "y"), "Aborted by user");
Expand Down
8 changes: 4 additions & 4 deletions source/dotfim/cmd/package.d
Expand Up @@ -7,7 +7,7 @@ import dotfim.dotfim;
public import dotfim.cmd.add;
public import dotfim.cmd.list;
public import dotfim.cmd.remove;
public import dotfim.cmd.sync;
public import dotfim.cmd.init;
public import dotfim.cmd.test;
public import dotfim.cmd.update;
public import dotfim.cmd.unsync;
Expand All @@ -24,7 +24,7 @@ class CmdHandler
auto options = DotfileManager.Options.process(args);
if (options.bNeededHelp) return;

// the start index of args to pass to cmd (e.g. add, remove, sync);
// the start index of args to pass to cmd (e.g. add, remove, init);
int start = 2;

if (args.length == 1)
Expand All @@ -45,8 +45,8 @@ class CmdHandler
Remove(CreateInstance(options),
args[start..$]);
break;
case "sync":
Sync(getcwd(), args[start..$]);
case "init":
Init(getcwd(), args[start..$]);
break;
case "unsync":
Unsync(CreateInstance(options));
Expand Down
2 changes: 1 addition & 1 deletion source/dotfim/cmd/test.d
Expand Up @@ -30,7 +30,7 @@ struct Test

exec();

writeln("Start with 'cd " ~ this.dir ~ " && dotfim sync repo/'");
writeln("Start with 'cd " ~ this.dir ~ " && dotfim init repo/'");
}

private void exec()
Expand Down
2 changes: 1 addition & 1 deletion source/dotfim/cmd/update.d
Expand Up @@ -343,7 +343,7 @@ unittest
{
import std.stdio;
import dotfim.util.test;
import dotfim.cmd : Add, Sync;
import dotfim.cmd : Add, Init;

string oldGitHash;
enum string checkHash = q{
Expand Down
4 changes: 2 additions & 2 deletions source/dotfim/dotfim.d
Expand Up @@ -321,15 +321,15 @@ mixin template SettingsTemplate()
this.settingsFile = settingsFileOrDir;

enforce(exists(this.settingsFile),
"\""~this.settingsFile~"\" does not exist. Please run dotfim sync");
"\""~this.settingsFile~"\" does not exist. Please run dotfim init");

import std.json;
auto json = parseJSON(readText(this.settingsFile));

// The settings json must contain our entries
enforce("dotPath" in json && "gitRepo" in json
&& "gitPath" in json,
"Please run dotfim sync");
"Please run dotfim init");

this.dotPath = json["dotPath"].str;
this.gitPath = json["gitPath"].str;
Expand Down
4 changes: 2 additions & 2 deletions source/dotfim/util/test.d
Expand Up @@ -66,8 +66,8 @@ TestDotfile line 3)";
{
Testdotfile.create;
Git.staticExecute(remotefolder, "init", "--bare");
import dotfim.cmd : Sync;
Sync s;
import dotfim.cmd : Init;
Init s;
settings.gitRepo = remotefolder;
s.gitRepo = remotefolder;
settings.settingsFile = settingsfile;
Expand Down

0 comments on commit 642b79c

Please sign in to comment.