DEV Community

Discussion on: How I made the open-dev.to CLI app with Python

Collapse
 
jasper_zanjani profile image
Jasper Zanjani • Edited

you could probably do this in a very short shell script

#!/bin/bash
if [ $# != 2 ]
then
  echo "Usage: dev.to tag"
  exit 1; 
else 
  firefox "https://dev.to/$1"
fi
Collapse
 
neex profile image
neex • Edited

Hmmm, I am failing to see how writing a shell script will teach you Python.

Collapse
 
jasper_zanjani profile image
Jasper Zanjani

I wonder if you were building a house and trying to use a hammer on a screw, would you be such a smartass if I proffered a screwdriver?

Thread Thread
 
neex profile image
neex

The whole point is that I am not building a house. I want to build one some day, so I practice my skills by building a table. And than a chair. It will cost me $500 in time and materials. I could of course go and pick one up in Ikea for $25 but that will not make building a house any easier.

Collapse
 
fronkan profile image
Fredrik Sjöstrand • Edited

So I came across this and I had to see how short I could make it in Python. This was the shortest I could make it while keeping it nice looking. Here I use start chrome ... as I am running it on a Windows box.

import os
import sys
page = '' if len(sys.argv) < 2 else f'/t/{sys.argv[1]}'
os.system(f'start chrome https://dev.to{page}')