`rewrite flush --hard` should create `.htaccess` if it does not exist
Right now flush --hard returns success, but it actually fails if there is no .htaccess file.
flush --hard should create .htaccess if it does not exist
A candidate for good-first-issue ?
Yes, this seems like a bug.
However, the behavior would need to be aware of Apache vs Nginx as well. Creating an .htaccess file on an Nginx installation will not do anything. This should then throw an error too. The question is then whether we can reliably detect the hosting configuration that make use of a .htaccess file...?
Maybe only do it if apache_modules: mod_rewrite. If you plan on writing to .htaccess, you should simply create it before doing so?
a touch() call before https://github.com/wp-cli/rewrite-command/blob/eaa88e5102eb81b1d230a385c42594d4506ecded/src/Rewrite_Command.php#L72 would do it
As closely as I can tell this is currently working as desired.
After installing WP and configuring permalinks then deleting .htaccess and the running wp rewrite flush --hard the .htaccess file is recreated and exits with 0.
Running rewrite flush --hard does create the .htaccess file if it doesn't already exist. I have run this command on both my local and remote setups, and I can confirm that it works as expected.
The only way that I can reproduce the issue is by removing the following lines from the ~/.wp-cli/config.yml, which is needed according to the command README.MD
apache_modules:
- mod_rewrite