diff --git a/CHANGELOG.md b/CHANGELOG.md index 96777e1..703e106 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 1.0.5 - WIP + +- Adding the option `-d` for the `init` command to initialize the ebook in a different directory + ## 1.0.4 - 28th December 2023 - Adding the option for customizing the working path (the directory with the assets folder) diff --git a/readme.md b/readme.md index d81e67e..d2a246c 100644 --- a/readme.md +++ b/readme.md @@ -43,11 +43,10 @@ composer require hi-folks/ibis-next Once the tool is installed, you will find the `vendor/` directory where you can find your new tool (`vendor/bin/ibis-next`). -Now you can initialize properly the directory via the `init` command for automatically creating the configuration file, the assets folder, and the content folder (for creating your Markdown files). -To launch the `init`` command: +If you install Ibis Next locally, in a specific directory, to launch and run Ibis Next you need to define the path like this: ~~~shell -./vendor/bin/ibis-next init +./vendor/bin/ibis-next list ~~~ ### Installing ibis-next globally @@ -59,7 +58,23 @@ Instead, if you prefer to install the composer package globally you can add the composer global require hi-folks/ibis-next ~~~ -Then, run this command inside an **empty directory**: +If you install Ibis Next globally, to launch and run Ibis Next you can use the `ibis-next` like this: + +~~~shell +ibis-next list +~~~ + +## Initializing the ebook + + +Now you can initialize properly the directory via the `init` command for automatically creating the configuration file, the assets folder, and the content folder (for creating your Markdown files). +If you installed Ibis Next locally, to launch the `init` command: + +~~~shell +./vendor/bin/ibis-next init +~~~ + +If you installed Ibis Next globally, you can run the `init` command inside an empty directory: ~~~shell ibis-next init @@ -78,6 +93,16 @@ This will create the following files and directories: You may configure your book by editing the `ibis.php` configuration file. +### Setting a specific directory + +If you want to initialize a specific empty directory (not the current one), you can use the `-d` option while you are running the `init` command, for example: + +~~~shell +ibis-next init -d ../some-other-directory +~~~ + +This is helpful for example if you want to install Ibis Next once and you want to create and manage multiple books. + ## Writing Your eBook The `init` command will create sample .md files inside the `content` folder. You can explore those files to see how you can write your book. @@ -88,15 +113,15 @@ Inside the `content` directory, you can write multiple `.md` files. Ibis uses th ~~~markdown # Part 1 -

tags define the start of a part. A separate PDF page will be generated to print the part title and any content below. +`

` tags define the start of a part. A separate PDF page will be generated to print the part title and any content below. ## Chapter 1 -

tags define the start of a chapter. A chapter starts on a new page always. +`

` tags define the start of a chapter. A chapter starts on a new page always. ### Starting with Ibis -

tags define different titles inside a chapter. +`

` tags define different titles inside a chapter. ~~~ ### Adding different quotes diff --git a/src/Commands/InitCommand.php b/src/Commands/InitCommand.php index cddc2f5..e5197cc 100644 --- a/src/Commands/InitCommand.php +++ b/src/Commands/InitCommand.php @@ -5,6 +5,7 @@ use Illuminate\Filesystem\Filesystem; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; class InitCommand extends Command @@ -13,6 +14,7 @@ class InitCommand extends Command private ?\Illuminate\Filesystem\Filesystem $disk = null; + /** * Configure the command. * @@ -22,7 +24,14 @@ protected function configure() { $this ->setName('init') - ->setDescription('Initialize a new project in the current directory.'); + ->addOption( + 'workingdir', + 'd', + InputOption::VALUE_OPTIONAL, + 'The path of the working directory where `ibis.php` and `assets` directory will be created', + '' + ) + ->setDescription('Initialize a new project in the working directory (current dir by default).'); } /** @@ -36,7 +45,23 @@ public function execute(InputInterface $input, OutputInterface $output): int $this->disk = new Filesystem(); $this->output = $output; - $currentPath = getcwd(); + $workingPath = $input->getOption('workingdir'); + if ($workingPath === "") { + $workingPath = "./"; + } elseif (!is_dir($workingPath)) { + $workingPath = "./"; + } + $ibisConfigPath = $workingPath . '/ibis.php'; + $contentPath = $workingPath . '/content/'; + + $this->output->writeln('Creating config/assets directory as: ' . $workingPath . ''); + $this->output->writeln('Creating config file as: ' . $ibisConfigPath . ''); + $this->output->writeln('Creating content directory as: ' . $contentPath . ''); + + + + + $currentPath = $workingPath; if ($this->disk->isDirectory($currentPath . '/assets')) { $this->output->writeln('');