donnieparka
defmodule Createproj do
@moduledoc """
Documentation for `Createproj`.
"""
def print_help do
IO.puts(
"Usage: newP" <>
" -f filepath: creates a new project\n" <>
"-b: adds boilerplate\n"
)
end
def write_boilerplate(project_name) do
file_name = project_name <> ".ex"
file_path = Path.join([project_name, file_name])
boilerplate = "defmodule #{project_name} do\nend"
File.write(file_path, boilerplate, [:append])
end
def get_filename(args) do
Enum.with_index(args)
|> Enum.find(fn {arg, index} -> arg == "-f" and index < length(args) - 1 end)
|> case do
{_, index} ->
Enum.at(args, index + 1)
{nil} ->
nil
end
end
def create_folder(project_name, file_name \\ "") do
folder_path = Path.join([project_name, file_name])
File.mkdir(folder_path)
|> case do
:ok -> IO.puts("created#{folder_path}")
{_, _} -> IO.puts("failed to make #{file_name}")
end
end
def main(args) do
IO.inspect(args)
new_file = Enum.member?(args, "-f")
boilerplate = Enum.member?(args, "-b")
cond do
new_file and not boilerplate ->
project_name = get_filename(args)
create_folder(project_name)
create_folder(project_name, "/lib")
create_folder(project_name, "/test")
new_file and boilerplate ->
project_name = get_filename(args)
create_folder(project_name)
create_folder(project_name, "/lib")
create_folder(project_name, "/test")
write_boilerplate(project_name)
true ->
print_help()
end
end
end
compilation works great but when I run:
~/projects ./createproj -f dio -b
** (MatchError) no match of right hand side value: "dio"
(createproj 0.1.0) lib/createproj.ex:33: Createproj.main/1
(elixir 1.18.1) lib/kernel/cli.ex:137: anonymous fn/3 in Kernel.CLI.exec_fun/2
If I run it from the iex like this:
Createproj.main(["-f", "cane", "-b"])
["-f", "cane", "-b"]
createdcane
createdcane/lib
createdcane/test
:ok
as you can see everything works… any idea what’s going on?
Trending in Questions
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
Hello,
I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
Hi everyone,
I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding.
I sta...
New
Documentation
While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
New
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
I’m new to elixir and just tried to install the elixirLS extension for VScode(ium) and it is throwing some errors that I would like help ...
New
Other Trending Topics
Edit: 2026 May 15 - This post is archived.
Mob is alive!!
Main docs: mob v0.7.11 — Documentation
A bit of explanation for the slightly c...
New
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Hi everyone!
The first release candidate for the Expert language server project is now available!
We’ve published a press release detai...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #ai
- #elixirconf-us
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #elixirconf-eu
- #metaprogramming
- #hex










Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
Eiji
I have tried this in newly generated project. I have only added
escript: [main_module: Createproj]toKeywordreturned inprojectfunction insidemix.exsand it works as expected. We would need something more to see where is the problem as for now I cannot reproduce it.al2o3cr
Line 33 of what you posted isn’t in
mainand couldn’t raise aMatchErroranyways:My guess is that a compiled version of
Createprojis running, confusing the situation.donnieparka
what else can i provide to help you understand? i already had that line in mix.exs so i am even more confused now
donnieparka
i rebooted and run it but still happens so it is impossible
dimitarvp
IMO you’re better off publishing a GitHub project demonstrating the issue at this point.
al2o3cr
The BEAM caches compiled bytecode to disk when it reads
.exfiles, so rebooting will not make a difference. Usually the advice is to remove the_buildfolder, but I’m not sure where that lives for escripts.sodapopcan
Heh, ya,
rm -rf _build depsis the general “turn it off an on again” for Mix projects. The nuclear option isrm -rf _build deps ~/.hexthough in six years of Elixiring that has only been necessary once (and I can’t even remember why).benwilson512
If this is an escript, you need to rebuild the escript after each change you make.
Eiji
It’s as nuclear as
rm -rf ~/.config- I would definitely not recommend that … In this directory there are:docs- cached docs, so (in very short) justHTMLstuffpackages- cached package archives (when fetching dependencies for every project)hex.config- auth file used when for example you publish a package or send it’s new versioncache.ets- I don’t remember now what’s for, so at in best case this should be the only cache file to removeSo removing this directory developer would have to sign in again in CLI and download again all deps and their docs for every project.
When compiling project in many cases a cache is saved in some directory in
~/.cachefolder (make sure to not remove the entire directory). Also in~/.cache/mixthere isinstallsdirectory and it’s used when callingMix.install/1in scripts andiex. Same deps for differentElixirandErlangversions are fetched and compiled in separate directories likeelixir-1.18.1-erts-15.2. There all “installs” used inMix.install/1are stored separately by generated hash of packages passed to this function. Therefore if you work always on latest versions only you may (but not need to) remove all directories in~/.cache/mix/installs/except the one for your latest version.Other directories that you may be interested is
~/.cache/erlang-historywhich stores not only data forErlang, but alsoElixir.Yeah, that reminds me I had similar fails - they happened way too often …
donnieparka
https://github.com/donnieparka/newP_elixir.git
that’s it anyway there’s nothing more than what i shared