ディレクトリオプションも追加

守矢諏訪子 <suwako@076.moe>、2026-07-12 07:04
コミット 023e3e13936694e021b129a7597a5d60f7022ba9 ・親 a2579cd ・ファイルを見る

1個のファイル、+4 -3

変更 newpost.php
@@ -35,13 +35,14 @@
3535 CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
3636 OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
3737 */
38-if (!isset($argv[1])) die('usage: php newpost.php [slug]');
39-if (file_exists("blog/{$argv[1]}.md")) die("エラー: ファイル「blog/{$argv[1]}.md」は既に存在します。\n");
38+if (!isset($argv[1])) die('usage: php newpost.php <slug> [dir]');
39+$dir = isset($argv[2]) ? $argv[2] : 'blog';
40+if (file_exists("{$dir}/{$argv[1]}.md")) die("エラー: ファイル「{$dir}/{$argv[1]}.md」は既に存在します。\n");
4041
4142 define('ROOT', realpath(__DIR__));
4243 require_once ROOT.'/config/config.php';
4344 include('util.php');
44-$post = fopen("blog/{$argv[1]}.md", "w");
45+$post = fopen("{$dir}/{$argv[1]}.md", "w");
4546 fwrite($post, "title: 【】\n");
4647 fwrite($post, "uuid: ".uuid()."\n");
4748 fwrite($post, "author: 諏訪子\n");