Good morning @ILM, today I started working a little bit more after I got my progress back and I was able to fix every issue except for the
“The rest of the commit messages should start with fix:
, feat:
, refactor:
, chore:
, or test:
”
issue and the
“You should finish your project while on the main
branch. Your working tree should be clean and you should not have any uncommitted changes”
issue. I also got another issue: “If you run ./element.sh
, it should output only Please provide an element as an argument.
and finish running.” Thank you for your help so far 
element.sh:
#!/bin/bash
PSQL="psql --username=freecodecamp --dbname=periodic_table -t --no-align -c"
if [[ -z $1 ]]
then
echo "Please provide an element as an argument."
else
if [[ $1 =~ ^[0-9]+$ ]]
then
ELEMENT=$($PSQL "SELECT * FROM elements INNER JOIN properties USING(atomic_number) INNER JOIN types USING(type_id) WHERE atomic_number=$1")
else
ELEMENT=$($PSQL "SELECT * FROM elements INNER JOIN properties USING(atomic_number) INNER JOIN types USING(type_id) WHERE symbol='$1' OR name='$1'")
fi
if [[ -z $ELEMENT ]]
then
echo "I could not find that element in the database."
else
echo $ELEMENT | while IFS="|" read TYPE_ID ATOMIC_NUMBER SYMBOL NAME ATOMIC_MASS MELTING_POINT BOILING_POINT TYPE
do
echo "The element with atomic number $ATOMIC_NUMBER is $NAME ($SYMBOL). It's a $TYPE, with a mass of $ATOMIC_MASS amu. $NAME has a melting point of $MELTING_POINT celsius and a boiling point of $BOILING_POINT celsius."
done
fi
fi
# TODO: Add more elements
if [[ $# -eq 0 ]]; then
echo 'Error: Please provide an element as an argument'
exit 1
fi
git log --oneline:
c8c9a10 (HEAD -> main) refactor: Add shebang to element.sh
198f588 fix: Add input validation to element.sh
30f584c chore: Add .gitignore file
fae0f0e docs: Add usage section to README
ca1dd50 feat: Add TODO for expanding element database
6f7f600 Initial commit
git-rebase-todo:
pick ca1dd50 feat: Add TODO for expanding element database
reword fae0f0e docs: Add usage section to README
pick 30f584c chore: Add .gitignore file
pick 198f588 fix: Add input validation to element.sh
pick c8c9a10 refactor: Add shebang to element.sh
git status:
On branch main
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: element.sh
no changes added to commit (use "git add" and/or "git commit -a")
\d elements:
Table "public.elements"
Column | Type | Collation | Nullable | Default
---------------+-----------------------+-----------+----------+---------
atomic_number | integer | | not null |
symbol | character varying(2) | | not null |
name | character varying(40) | | not null |
Indexes:
"elements_pkey" PRIMARY KEY, btree (atomic_n
umber)
"elements_atomic_number_key" UNIQUE CONSTRAI
NT, btree (atomic_number)
"unique_name" UNIQUE CONSTRAINT, btree (name
)
"unique_symbol" UNIQUE CONSTRAINT, btree (sy
mbol)
Referenced by:
TABLE "properties" CONSTRAINT "properties_at
omic_number_fkey" FOREIGN KEY (atomic_number) RE
FERENCES elements(atomic_number)
\d properties:
Table "public.properties"
Column | Type | Collation | N
ullable | Default
-----------------------+---------+-----------+--
--------+---------
atomic_number | integer | | n
ot null |
atomic_mass | numeric | | n
ot null |
melting_point_celsius | numeric | | n
ot null |
boiling_point_celsius | numeric | | n
All selected from elements:
atomic_number | symbol | name
---------------+--------+-----------
1 | H | Hydrogen
2 | He | Helium
3 | Li | Lithium
4 | Be | Beryllium
5 | B | Boron
6 | C | Carbon
7 | N | Nitrogen
8 | O | Oxygen
9 | F | Fluorine
10 | Ne | Neon
All selected from properties:
atomic_number | atomic_mass | melting_point_cel
sius | boiling_point_celsius | type_id
---------------+-------------+------------------
-----+-----------------------+---------
1 | 1.008 | -2
59.1 | -252.9 | 2
2 | 4.0026 | -2
72.2 | -269 | 2
3 | 6.94 | 18
0.54 | 1342 | 1
4 | 9.0122 |
1287 | 2470 | 1
6 | 12.011 |
3550 | 4027 | 2
7 | 14.007 | -2
10.1 | -195.8 | 2
8 | 15.999 |
-218 | -183 | 2
9 | 18.998 |
-220 | -188.1 | 2
10 | 20.18 | -2
48.6 | -246.1 | 2
I’m getting close, I can feel it!